singlebrook / utf8-cleaner

MIT License
277 stars 44 forks source link

TypeError: expected Hash (got String) for param `_REQUEST' #16

Closed johnnyshields closed 10 years ago

johnnyshields commented 10 years ago

Installed UTF-8 cleaner, seems to have resolved UTF-8 conversion errors in request, but now I'm seeing the following occasionally. Wondering if anyone else has seen the same?

TypeError: expected Hash (got String) for param `_REQUEST'
gems/rack-1.4.5/lib/rack/utils.rb:127:in normalize_params
    from gems/rack-1.4.5/lib/rack/utils.rb:96:in block in parse_nested_query
    from gems/rack-1.4.5/lib/rack/utils.rb:93:in each
    from gems/rack-1.4.5/lib/rack/utils.rb:93:in parse_nested_query
    from gems/rack-1.4.5/lib/rack/request.rb:332:in parse_query
    from gems/rack-1.4.5/lib/rack/request.rb:186:in GET
    from gems/rack-1.4.5/lib/rack/request.rb:221:in params
    from bundler/gems/remotipart-4b75722c2565/lib/remotipart/middleware.rb:12:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/params_parser.rb:21:in call
    from /mnt/tablesolution-production/current/gems/vesper_ext/lib/vesper_ext/middleware/catch_json_errors.rb:13:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/flash.rb:242:in call
    from gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in context
    from gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/cookies.rb:341:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/callbacks.rb:28:in block in call
    from gems/activesupport-3.2.18/lib/active_support/callbacks.rb:405:in _run__1640190139283734739__call__3111014343171907194__callbacks
    from gems/activesupport-3.2.18/lib/active_support/callbacks.rb:405:in __run_callback
    from gems/activesupport-3.2.18/lib/active_support/callbacks.rb:385:in _run_call_callbacks
    from gems/activesupport-3.2.18/lib/active_support/callbacks.rb:81:in run_callbacks
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/callbacks.rb:27:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/remote_ip.rb:31:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/debug_exceptions.rb:16:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/show_exceptions.rb:56:in call
    from gems/lograge-0.2.2/lib/lograge/rails_ext/rack/logger.rb:15:in call_app
    from gems/railties-3.2.18/lib/rails/rack/logger.rb:16:in block in call
    from gems/activesupport-3.2.18/lib/active_support/tagged_logging.rb:22:in tagged
    from gems/railties-3.2.18/lib/rails/rack/logger.rb:16:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/request_id.rb:22:in call
    from gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in call
    from gems/rack-1.4.5/lib/rack/runtime.rb:17:in call
    from gems/activesupport-3.2.18/lib/active_support/cache/strategy/local_cache.rb:72:in call
    from gems/actionpack-3.2.18/lib/action_dispatch/middleware/static.rb:63:in call
    from gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in forward
    from gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in fetch
    from gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in lookup
    from gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in call!
    from gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in call
    from gems/utf8-cleaner-0.0.9/lib/utf8-cleaner/middleware.rb:18:in call
    from gems/railties-3.2.18/lib/rails/engine.rb:484:in call
    from gems/railties-3.2.18/lib/rails/application.rb:231:in call
    from gems/railties-3.2.18/lib/rails/railtie/configurable.rb:30:in method_missing
    from gems/unicorn-4.6.3/lib/unicorn/http_server.rb:552:in process_client
    from gems/unicorn-4.6.3/lib/unicorn/http_server.rb:632:in worker_loop
    from gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500:in spawn_missing_workers
    from gems/unicorn-4.6.3/lib/unicorn/http_server.rb:511:in maintain_worker_count
    from gems/unicorn-4.6.3/lib/unicorn/http_server.rb:277:in join
    from gems/unicorn-4.6.3/bin/unicorn_rails:209:in <top (required)>
    from bin/unicorn_rails:23:in load
    from bin/unicorn_rails:23:in <main>
sbleon commented 10 years ago

@johnnyshields that's unrelated to utf8-cleaner. It's the result of a invalid combination of URL params, e.g. from a request like /index.php?_REQUEST=&_REQUEST[option]=com_content. I think those are Joomla-style URLs. Rack chokes on the presence of both a simple value (the empty string) and nested, hash-style values in the same parameter (_REQUEST).

I think another little Rack middleware would be a nice solution to this common problem.