Head response with no body produces 500 Internal Server Error
brcarp opened this issue · comments
I'm thinking there's an assumption here that there's a non-nil body
in the response:
In a Rails action that uses head
and no body in the response, the following error results:
Critical exception from handler
{
"errorMessage": "undefined method `empty?' for nil:NilClass",
"errorType": "Function<NoMethodError>",
"stackTrace": [
"/var/task/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/deflater.rb:99:in `block in each'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.6.2/lib/action_dispatch/http/response.rb:145:in `each'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.6.2/lib/action_dispatch/http/response.rb:145:in `each_chunk'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.6.2/lib/action_dispatch/http/response.rb:126:in `each'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.6.2/lib/action_dispatch/http/response.rb:74:in `each'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.6.2/lib/action_dispatch/http/response.rb:473:in `each'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/body_proxy.rb:41:in `method_missing'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/body_proxy.rb:41:in `method_missing'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/body_proxy.rb:41:in `method_missing'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/deflater.rb:96:in `each'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/lamby-3.1.1/lib/lamby/handler.rb:43:in `block in body'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/lamby-3.1.1/lib/lamby/handler.rb:42:in `tap'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/lamby-3.1.1/lib/lamby/handler.rb:42:in `body'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/lamby-3.1.1/lib/lamby/handler.rb:23:in `response'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/lamby-3.1.1/lib/lamby/handler.rb:7:in `call'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/lamby-3.1.1/lib/lamby.rb:25:in `handler'",
"/var/task/app.rb:23:in `handler'"
]
}
I've had issues creating a failing test (see here 80bbe4d) or even generating an error in a few production instances using some curl -I ...
tests. Can you share more on the context and maybe how to generate an error in a test condition?
Ack. Okay, it turns out Lamby wasn't the culprit here, but rather Rack::Deflater
. The application in question is configured strangely for 4xx errors in its weird soup of Rack middleware, custom error pages, the Lamby handler, and Rails application configuration. I still haven't gotten to the bottom of it but needless to say I think we can close this issue.
Thanks Brian! We do have rack deflater tests in place just in case. @avinash-vllbh helped there. So if you think there is a way to express a use test case and Lamby is the obvious fix... let me know!!!