-
Notifications
You must be signed in to change notification settings - Fork 369
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
Fix NoMethodError when ActionController::Metal#response is an Array #420
Conversation
when ActionDispatch::Response | ||
response.status | ||
when Array | ||
status = response.first |
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.
the first element always contain the status? If yes, can you add a comment explaining why the first and if we have to change this behavior in the future?
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.
Yes, it's always the first because that's the Rack response standard: status code, headers, body.
8273d54
to
f579dfb
Compare
Pull request for Devise opened here: heartcombo/devise#4871 |
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.
One small question about disabling rubocop warning. Otherwise looks Good!
@@ -231,6 +232,20 @@ def process_action(*args) | |||
ensure | |||
Datadog::Contrib::Rails::ActionController.finish_processing(payload) | |||
end | |||
|
|||
# rubocop:disable Style/EmptyElse |
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.
What are the benefits of using empty else here ?
Also is # rubocop:disable Style/EmptyElse
reenabled after the scope of this method ?
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.
Okay, I thought that a case
block would return the object passed into the case
statement if none of the branches are hit. Since I wanted it to return nil
, I thought I needed to be explicit. Turns out its just another one of those weird language things where it does in fact return nil
if no branches are met. Probably should remove it then.
f579dfb
to
f9a9635
Compare
@pawelchcki Feedback addressed. |
Thanks @delner, looks good. |
When
ActionController::Metal#response
was anArray
instead of aActionDispatch::Response
, tracing raised an error. This manifested in Devise'sFailureApp
which is overriding the value ofresponse
with an Array, in an unexpected way. You can reproduce this by attempting to login with bad credentials.Only affects users who use Devise and ddtrace 0.12.0.
This pull request attempts to handle both
ActionDispatch::Response
andArray
responses, and if it doesn't receive either, it doesn't set a status.Addresses #419