-
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
These exceptions are not handled when parsing query params.
We need to rescue them when building params and whenever we are calling Rack::Utils.parse_nested_query
| potential_version = Rack::Utils.parse_nested_query(env[Rack::QUERY_STRING])[parameter_key] |
grape/lib/grape/middleware/formatter.rb
Line 143 in 12dc739
| fmt = Rack::Utils.parse_nested_query(env[Rack::QUERY_STRING])[FORMAT] |
This test will raise an Rack::QueryParser::ParamsTooDeepError. Nonetheless, having a rescue_from :all would handle it but I don't think its user's responsibility.
context 'query params ParamsTooDeepError' do subject { last_response } let(:params) do "foo#{"[a]" * Rack::Utils.param_depth_limit}=bar" end let(:api) do Class.new(described_class) do get { 'yes!' } end end let(:app) { api } before { get "/?#{params}" } it { is_expected.to be_successful } endHere are other cases from Rack's test suite
https://github.com/rack/rack/blob/df241355a7f122dc22437398267c1d5f0b27e1ad/test/spec_utils.rb#L230-L239
In the end, we should return a 400 according to Rack