-
-
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
Validation Errors in 0.5.0 #428
Comments
Update: This can be solved by removing memoization in |
Update: Tracked it down. By moving memoization to the request level, any Grape middleware that is added to the stack before the formatter has the potential to freeze the value. Commit coming momentarily. |
Re: spec. What middleware are you inserting before the formatter? I tried to insert a dummy middleware before the formatter that would do something to the request, but that didn't produce the desired error. Is it possible that that middleware needs to be fixed instead of removing |
It was the Grape OAuth2 middleware (it has to be something that inherits from Grape::Middleware::Base). I'll try to contribute a minimal spec that breaks under the old code. |
@mbleigh, I almost re-added this Maybe another way to solve this is to assign @env['grape.request.params'] and @env['grape.request.headers'] elsewhere, in a global middleware? require 'grape/middleware/base'
module Grape
module Middleware
class Globals < Base
def before
@env['grape.request'] = Grape::Request.new(@env)
@env['grape.request.headers'] = request.headers
@env['grape.request.params'] = request.params if @env['rack.input']
end
end
end
end We could then try to stop creating |
I'm just posting this to see if anyone else has run into this...I tried to upgrade Divshot to Grape 0.5.0 and started immediately seeing unexpected 400 errors for "missing" required parameters that were present in the request. Here's what I've determined so far:
params
request taking place before the Formatter middleware has had a chance to parse the request body.Is anyone else experiencing this issue? I'm still investigating.
The text was updated successfully, but these errors were encountered: