Closed beanieboi closed 8 years ago
hey all!
a quick update on this. it looks like the fake_braintree server or some middleware that runs before rack-protection is not correctly setting the Content-Type header. it's not a bug on rack-protection since the rack spec says that header fields must be strings.
i'll keep digging, because thats a really weird bug :)
Nice find! I'm going to close this since it seems like the bug isn't here, but if you change your mind just reopen it and we can talk :)
@kytrinyx oh yeah, thanks! i forgot to close :)
i actually chased it down to the Bitbucket gem extending NilClass to respond to content_type
https://github.com/vongrippen/bitbucket/blob/master/lib/bitbucket_rest_api/result.rb#L21-L23 https://github.com/vongrippen/bitbucket/blob/master/lib/bitbucket_rest_api/response/helpers.rb#L8-L18
because of this, Sinatra enters the wrong branch of the if
over here: https://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L910-L914
body[0]
is a NilClass and therefor does not set the content-type to HTML for a redirect.
we (read I :D) have to fix the Bitbucket gem to not patch NilClass.
cc https://github.com/highfidelity/fake_braintree/issues/111
I love a good mystery, thanks for sharing :)
hey!
i currently debugging a weird problem. our setup: we have a Rails application that uses fake_braintree (http://github.com/highfidelity/fake_braintree) for testing. during our tests, we hit the fake braintree server and expect some JSON responses. the fake braintree server runs Sinatra with rack-protection. We had 1 very flaky test, where we couldn't parse the JSON coming from fake braintree. after some debugging, it turned out that the fake braintree server was returning a 500 error message and not JSON.
thats why i'm here. i try to debug the exception but i have no glue so far, why this is happening.
the exception
RACK_ENV
parsed headers used by the
html?
methodit turns out that Content-Type is nil, although the RACK_ENV says that it is
application/x-www-form-urlencoded
so something between handing the headers to rack-protection goes wrong and rack protection blows up when it's trying to figure out the content type.
do you have any hints where i could start debugging this?
would it be ok for to just add a nil check to
html?
so it doesn't blow up anymore and we can safely return false?i'm happy to debug and prepare a PR, but would love to get a heads start from you girls and guys.
a gist with the complete dump: https://gist.github.com/beanieboi/9fe9892842820b8ec915
for reference: https://github.com/highfidelity/fake_braintree/issues/111