-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
NoMethodError for nil:NilClass on headers.reverse_merge after upgrading Grape from 1.6.2 to 1.8.0 #2481
Comments
I would start by writing a spec in Grape 1.6 to reproduce this and bisect to a change between 1.6 and 1.8. There has also been quite a few rack-related changes since 1.8. We can see if that test passes now and commit the test to ensure it doesn't break in the future. |
@alekgosk headers is grape/lib/grape/middleware/error.rb Line 53 in a6cde5d
error! where the 3rd parameter is nil ?
|
Good catch @ericproulx, the culrpit is currently the following code: # this code comes from a trait
rescue_from :grape_exceptions do |e|
# e.headers is nil here when request body is malformed
error! e.message, e.status, e.headers
end |
#2342 introduced the block execution of a |
Thanks for digging this up @ericproulx! @alekgosk close? |
Yup, I think we can close it, thanks @dblock |
Environment
Description
After upgrading Grape from version 1.6.2 to 1.8.0, we started encountering a
NoMethodError
fornil:NilClass
when callingreverse_merge
on theheaders
variable. This issue occurs in our custom middleware where we manipulate the headers.Steps to Reproduce
reverse_merge
on theheaders
variable.Expected Behavior
The
headers
variable should be able to merge with another hash without throwing an error, as it worked in Grape version 1.6.2.Actual Behavior
The application throws a
NoMethodError
indicating thatreverse_merge
is called onnil:NilClass
. This suggests that theheaders
variable isnil
at the time of the call.Error Log
Rspec test that is failing
The text was updated successfully, but these errors were encountered: