{"action":"closed","issue":{"url":"https://api.github.com/repos/ruby-grape/grape/issues/1116","labels_url":"https://api.github.com/repos/ruby-grape/grape/issues/1116/labels{/name}","comments_url":"https://api.github.com/repos/ruby-grape/grape/issues/1116/comments","events_url":"https://api.github.com/repos/ruby-grape/grape/issues/1116/events","html_url":"https://github.com/ruby-grape/grape/issues/1116","id":102414977,"number":1116,"title":"Incompatibility between 0.13.0 and Warden","user":{"login":"qbyt","id":149029,"avatar_url":"https://avatars.githubusercontent.com/u/149029?v=3","gravatar_id":"","url":"https://api.github.com/users/qbyt","html_url":"https://github.com/qbyt","followers_url":"https://api.github.com/users/qbyt/followers","following_url":"https://api.github.com/users/qbyt/following{/other_user}","gists_url":"https://api.github.com/users/qbyt/gists{/gist_id}","starred_url":"https://api.github.com/users/qbyt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qbyt/subscriptions","organizations_url":"https://api.github.com/users/qbyt/orgs","repos_url":"https://api.github.com/users/qbyt/repos","events_url":"https://api.github.com/users/qbyt/events{/privacy}","received_events_url":"https://api.github.com/users/qbyt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-21T16:26:59Z","updated_at":"2015-08-22T12:14:36Z","closed_at":"2015-08-22T12:14:36Z","body":"Hi, \r\n\r\nWe're experiencing a Warden compatibility issue upgrading a Grape app from 0.11.0 to 0.13.0.\r\n\r\nWhen we attempt to access a URL which requires authentication we get this trace: \r\n\r\n```\r\nNoMethodError: undefined method `[]' for nil:NilClass\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:154:in `block in call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:75:in `optimized_each'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/grape-0.13.0/lib/grape/api.rb:114:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/grape-0.13.0/lib/grape/api.rb:44:in `call!'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/grape-0.13.0/lib/grape/api.rb:39:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/urlmap.rb:66:in `block in call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `each'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.1.1/lib/honeybadger/rack/metrics_reporter.rb:17:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.1.1/lib/honeybadger/rack/error_notifier.rb:33:in `block in call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.1.1/lib/honeybadger/config.rb:190:in `with_request'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.1.1/lib/honeybadger/rack/error_notifier.rb:30:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-ssl-enforcer-0.2.9/lib/rack/ssl-enforcer.rb:57:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/tempfile_reaper.rb:15:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/lint.rb:49:in `_call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/lint.rb:37:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/showexceptions.rb:24:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/commonlogger.rb:33:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:218:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/chunked.rb:54:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:53:in `process'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:39:in `receive_data'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run_machine'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/backends/base.rb:73:in `start'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/server.rb:162:in `start'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in `run'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:147:in `start'\r\n        /Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/bin/rackup:4:in `<top (required)>'\r\n        /Users/matt/.rbenv/versions/2.2.2/bin/rackup:23:in `load'\r\n        /Users/matt/.rbenv/versions/2.2.2/bin/rackup:23:in `<main>'\r\n```\r\n\r\nAfter realising that the issue went away with authentication disabled, we did some debugging from within Warden which lead us to this code: https://github.com/hassox/warden/blob/74162f2bf896b377472b6621ed1f6b40046525f4/lib/warden/manager.rb#L27-L50\r\n\r\nWe found that with 0.11.0, running this code: \r\n```ruby\r\nenv['warden'] = Proxy.new(env, self)\r\n@app.call(env)\r\n```\r\nat a breakpoint placed after line 30 of the above snippet, that a rack response body was returned:\r\n\r\n```\r\n=> [200,\r\n {\"Content-Type\"=>\"application/json\", \"Content-Length\"=>\"14\"},\r\n #<Rack::BodyProxy:0x007fd5fd1cf388\r\n  @block=\r\n   #<Proc:0x007fd5fd1cf2e8@/Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:654>,\r\n  @body=\r\n   #<Rack::BodyProxy:0x007fd5fd1cf5e0\r\n    @block=#<Proc:0x007fd5fd1cf518@/Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/response.rb:82>,\r\n    @body=\r\n     #<Rack::Response:0x007fd5fd1cf9c8\r\n      @block=nil,\r\n      @body=[\"{\\\"hello\\\":\\\"hi\\\"}\"],\r\n      @chunked=false,\r\n      @header={\"Content-Type\"=>\"application/json\", \"Content-Length\"=>\"14\"},\r\n      @length=14,\r\n      @status=200,\r\n      @writer=#<Proc:0x007fd5fd1cf798@/Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/response.rb:30 (lambda)>>,\r\n    @closed=false>,\r\n  @closed=false>]\r\n```\r\nAfter escaping from this breakpoint, the request completes successfully.\r\n\r\nWhereas with 0.13.0, we got the following return value:\r\n```\r\n=> #<Rack::Response:0x007fa522ba30a0\r\n @block=nil,\r\n @body=[\"{\\\"hello\\\":\\\"hi\\\"}\"],\r\n @chunked=false,\r\n @header={\"Content-Type\"=>\"application/json\", \"Content-Length\"=>\"14\"},\r\n @length=14,\r\n @status=200,\r\n @writer=#<Proc:0x007fa522ba2f38@/Users/matt/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/response.rb:30 (lambda)>>\r\n```\r\nand on continuation, we get the trace above.\r\n\r\nIt'd be great if you could explain whether or not this is intended behaviour, and if it is, what an appropriate workaround might be from our side. \r\n\r\nThanks in advance for your help (and thanks for Grape too! :smiley:)."}}