ActionController::BadRequest: Invalid query parameters: Invalid encoding for parameter:

This issue causes HTTP 500 errors in production and makes SRE pagers go off. Requests like this should get an HTTP 4xx response (probably 400?). Very similar to #609 (closed). Also consider #608 (closed), which is not about UTF-8, but could also be described as "characters we don't want in paths".

Note that Rails is trying to return a 400 status code with the special ActionController::BadRequest exception ("Bad Request" is the name of 400) but it's not being caught. #610 (comment 426377015)

https://sentry.gitlab.net/gitlab/gitlabcom/issues/1858275/?referrer=gitlab_plugin

Rack::QueryParser::InvalidParameterError: Invalid encoding for parameter: ������������������������������������������������windows��win.ini
  action_dispatch/request/utils.rb:39:in `check_param_encoding'
    raise Rack::Utils::InvalidParameterError, "Invalid encoding for parameter: #{params.scrub}"
  action_dispatch/request/utils.rb:32:in `block in check_param_encoding'
    params.each { |element| check_param_encoding(element) }
  action_dispatch/request/utils.rb:32:in `each'
    params.each { |element| check_param_encoding(element) }
  action_dispatch/request/utils.rb:32:in `check_param_encoding'
    params.each { |element| check_param_encoding(element) }
  action_dispatch/request/utils.rb:34:in `block in check_param_encoding'
    params.each_value { |value| check_param_encoding(value) }
...
(69 additional frame(s) were not displayed)

ActionController::BadRequest: Invalid query parameters: Invalid encoding for parameter: ������������������������������������������������windows��win.ini

Related incidents

Edited by Jacob Vosmaer