postrank-labs/goliath

Missing raise Goliath::Validation::BadRequestError on Rack::Params middleware

oriolfa opened this issue · 1 comments

On https://github.com/postrank-labs/goliath/blob/master/lib/goliath/rack/params.rb#L20 we are not rescuing a possible exception raised by ::Rack::Utils.parse_nested_query if the QUERY_STRING cannot be parsed. We should do the same as in https://github.com/postrank-labs/goliath/blob/master/lib/goliath/rack/params.rb#L44, where we parse POST bodies.

As an example on our app:

[13600:ERROR] 2013-11-15 17:52:09 :: invalid %-encoding (uggc%3N%2S%2S1928.16837.19314.81%2S)
[13600:ERROR] 2013-11-15 17:52:09 :: /home/epdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/uri/common.rb:898:in `decode_www_form_component'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/utils.rb:42:in `unescape'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/utils.rb:94:in `block (2 levels) in parse_nested_query'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/utils.rb:94:in `map'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/utils.rb:94:in `block in parse_nested_query'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/utils.rb:93:in `each'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/utils.rb:93:in `parse_nested_query'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/rack/params.rb:20:in `retrieve_params'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/rack/params.rb:60:in `block in call'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/rack/validator.rb:40:in `safely'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/rack/params.rb:59:in `call'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/rack/async_middleware.rb:73:in `call'
/home/user/app/shared/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
/home/user/app/shared/bundle/ruby/1.9.1/gems/async-rack-0.5.1/lib/async_rack/async_callback.rb:114:in `call'
/home/user/app/shared/bundle/ruby/1.9.1/gems/async-rack-0.5.1/lib/async_rack/async_callback.rb:91:in `block in new'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/request.rb:163:in `call'
/home/user/app/shared/bundle/ruby/1.9.1/gems/goliath-1.0.1/lib/goliath/request.rb:163:in `block in process'
[13600:INFO] 2013-11-15 17:52:09 :: [app][500] GET /hit c=pyvpx&gbxra=138453432877825996864&freire=uggc%3N%2S%2S1928.16837.19314.81%2S&fbhepr= in 1.21 ms

fixed in #268