Problem/Motivation

Reads from InputBag (e.g., $request->query->get('_wrapper_format', $request->getRequestFormat())) throw BadRequest if the value is non-scalar, but that's used in a few places that don't handle it. For example, HttpExceptionSubscriberBase, where that can actually turn a BadRequestHttpException into a server error because it hits the BadRequest while trying to read _wrapper_format.

This should actually be a client error, not a server error, and it can mislead operators when these requests appear to be problems (i.e., 500 errors in logs), and are not detected as bad client behavior (400 responses).

Steps to reproduce

% curl -v 'https://drupal.ddev.site?_wrapper_format%5B0%5D=foo'
...
< HTTP/2 500
...
The website encountered an unexpected error. Try again later.<br /><details class="error-with-backtrace"><summary><em class="placeholder">Symfony\Component\HttpFoundation\Exception\BadRequestException</em>: Input value &quot;_wrapper_format&quot; contains a non-scalar value. in <em class="placeholder">Symfony\Component\HttpFoundation\InputBag-&gt;get()</em> (line <em class="placeholder">46</em> of <em class="placeholder">vendor/symfony/http-foundation/InputBag.php</em>).</summary><pre class="backtrace">Symfony\Component\HttpFoundation\InputBag-&gt;get() (Line: 97)
Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase-&gt;onException() (Line: 254)
Symfony\Component\EventDispatcher\EventDispatcher::{closure:Symfony\Component\EventDispatcher\EventDispatcher::optimizeListeners():249}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher-&gt;callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch() (Line: 248)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleThrowable() (Line: 94)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle() (Line: 53)
Drupal\Core\StackMiddleware\Session-&gt;handle() (Line: 30)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength-&gt;handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength-&gt;handle() (Line: 199)
Drupal\page_cache\StackMiddleware\PageCache-&gt;fetch() (Line: 136)
Drupal\page_cache\StackMiddleware\PageCache-&gt;lookup() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle() (Line: 71)
Drupal\Core\StackMiddleware\AjaxPageState-&gt;handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle() (Line: 750)
Drupal\Core\DrupalKernel-&gt;handle() (Line: 34)
Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner-&gt;run() (Line: 32)
require() (Line: 20)
require_once() (Line: 13)
</pre></details>
curl -v 'https://drupal.ddev.site?_format%5B0%5D=foo'
curl -v 'https://drupal.ddev.site?destination%5B0%5D=foo'

Proposed resolution

Generally, throw BadRequestHttpException in these cases, except in HttpExceptionSubscriberBase, which needs to handle it, not throw. In that one, use the default wrapper format.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3631357

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

travis-bradbury created an issue. See original summary.

travis-bradbury’s picture

Issue summary: View changes
travis-bradbury’s picture

Status: Active » Needs review