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
Fixes issue #5660: Failsafe exception returns text/html and text/plain. #7636
Conversation
@@ -47,7 +54,7 @@ def render_exception(env, exception) | |||
response[1]['X-Cascade'] == 'pass' ? pass_response(status) : response | |||
rescue Exception => failsafe_error | |||
$stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}" | |||
FAILSAFE_RESPONSE | |||
env['HTTP_ACCEPT'] == 'text/html' ? FAILSAFE_RESPONSE_HTML : FAILSAFE_RESPONSE_PLAIN_TEXT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be =~
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't have to be, but that's probably better.
Nah, in theory this should never be triggered, so I am lazy to keep two versions. Why not just always return text/plain then? |
I can also make that change, if you think it's better. The only advantage of returning |
Updated. Now we only return text/plain. |
cc/ @josevalim |
@steveklabnik could you add a CHANGELOG entry? I'll merge this one. |
@rafaelfranca done. |
This pull request cannot be automatically merged. |
Yeah I'm an idiot, fixing now. |
It's best to just return text/plain when something has gone terribly wrong. Fixes rails#5660.
Fixes issue #5660: Failsafe exception returns text/html and text/plain.
If the request format is text/html then return the existing failsafe
response. For all other formats return text/plain.
The original issue points out to return JSON at the appropriate time,
however as @wycats pointed out, it's often better to return text/plain.