Merge pull request #16886 from yuki24/bugfix-bad-request-from-public-exception-4-1-stable

[4-1-stable] Fix a bug where malformed query strings lead to 500