Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhooks coming in as application/xml format #1167

Open
jcohenho opened this issue Apr 9, 2024 · 4 comments
Open

Webhooks coming in as application/xml format #1167

jcohenho opened this issue Apr 9, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@jcohenho
Copy link

jcohenho commented Apr 9, 2024

Issue

The issue mentioned in this older issue seems to have reappeared.

Webhook requests are being sent with an application/xml format, while the content-type is application/json; charset=utf-8

(ruby@puma: cluster worker 3: 20263 [project]#20280) request.format
#<Mime::Type:0x00000001074a58c8 @hash=-2878860039138727470, @string="application/xml", @symbol=:xml, @synonyms=["text/xml", "application/x-xml"]>


(ruby@puma: cluster worker 3: 20263 [project]#20280) request.content_type
"application/json; charset=utf-8"

Is this to be expected behavior?

Expected Behavior

I expect the request should be sent as a JSON format.

@jcohenho jcohenho added the bug Something isn't working label Apr 9, 2024
@tomer-stripe
Copy link
Collaborator

Hey @jcohenho! Could you share the headers you're seeing from the Stripe CLI?

@jcohenho
Copy link
Author

@tomer-stripe Here's an output from the request headers, note the HTTP_ACCEPT value:

(ruby@puma: cluster worker 2: 39111 [side_project]#39127) request.headers.to_h
{"rack.version"=>[1, 6],
 "rack.errors"=>#<IO:<STDERR>>,
 "rack.multithread"=>true,
 "rack.multiprocess"=>false,
 "rack.run_once"=>false,
 "rack.url_scheme"=>"http",
 "SCRIPT_NAME"=>"",
 "QUERY_STRING"=>"",
 "SERVER_PROTOCOL"=>"HTTP/1.1",
 "SERVER_SOFTWARE"=>"puma 5.6.4 Birdie's Version",
 "GATEWAY_INTERFACE"=>"CGI/1.2",
 "REQUEST_METHOD"=>"POST",
 "REQUEST_PATH"=>"/webhooks/stripe",
 "REQUEST_URI"=>"/webhooks/stripe",
 "HTTP_VERSION"=>"HTTP/1.1",
 "HTTP_HOST"=>"localhost:3000",
 "HTTP_USER_AGENT"=>"Stripe/1.0 (+https://stripe.com/docs/webhooks)",
 "CONTENT_LENGTH"=>"3107",
 "HTTP_ACCEPT"=>"*/*; q=0.5, application/xml",
 "HTTP_CACHE_CONTROL"=>"no-cache",
 "CONTENT_TYPE"=>"application/json; charset=utf-8",
 "HTTP_STRIPE_SIGNATURE"=>"redacted",
 "HTTP_ACCEPT_ENCODING"=>"gzip",
 "puma.request_body_wait"=>0,
 "SERVER_NAME"=>"localhost",
 "SERVER_PORT"=>"3000",
 "PATH_INFO"=>"/webhooks/stripe",
 "REMOTE_ADDR"=>"::1",
 "puma.socket"=>#<TCPSocket:fd 24, AF_INET6, ::1, 3000>,
 "rack.hijack?"=>true,
 "rack.hijack"=>#<Puma::Client:0xb220 @ready=true>,
 "rack.input"=>#<StringIO:0x000000010a685bu8>,
 "rack.after_reply"=>[],
 "puma.config"=>

@tomer-stripe
Copy link
Collaborator

Thank you! Let me poke more. We mostly pass the headers through 1:1 so that's a little odd

for k, v := range headers {
req.Header.Add(k, v)
}
// add custom headers
for k, v := range c.headers {
if strings.ToLower(k) == "host" {
req.Host = v
} else {
req.Header.Add(k, v)
}
}

@tomer-stripe
Copy link
Collaborator

@jcohenho Stripe itself is actually sending webhooks with that accept header. I confirmed that internally and with a test webhook: https://webhook.site/#!/view/6ffabbfa-a78d-4565-94ae-f6eec71f0718/8855e849-c425-4735-a629-bf7c2049e15b/1

I'm not sure if having the CLI change the behavior would be a good idea since this is how the data will be sent to you once you're in production too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants