Problem/Motivation
On a base Drupal 11 install, when navigating to /big_pipe/no-js?destination= a 500 error occurs
The website encountered an unexpected error. Try again later.
InvalidArgumentException: Cannot redirect to an empty URL. in Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl() (line 68 of /var/lib/tugboat/stm/vendor/symfony/http-foundation/RedirectResponse.php).
Drupal\Component\HttpFoundation\SecuredRedirectResponse->setTargetUrl('') (Line: 39)
Symfony\Component\HttpFoundation\RedirectResponse->__construct('') (Line: 53)
Drupal\big_pipe\Controller\BigPipeController->setNoJsCookie(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 638)
Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():638}()
Fiber->start() (Line: 639)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 30)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 71)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 753)
Drupal\Core\DrupalKernel->handle(Object) (Line: 34)
Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (Line: 32)
require('/var/lib/tugboat/stm/vendor/autoload_runtime.php') (Line: 22)
require_once('/var/lib/tugboat/stm/web/autoload_runtime.php') (Line: 13)
Steps to reproduce
Proposed resolution
Checking for an empty destination should resolve this issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | big_pipe_fix_empty_destination_test.patch | 1.19 KB | realgt |
| #6 | big_pipe_fix_empty_destination.patch | 1.04 KB | realgt |
Issue fork drupal-3616298
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
Comment #2
realgt commented11.4.x patch to resolve issue attached.
Comment #3
realgt commentedfixed issue with first patch
Comment #4
realgt commentedfixed trailing line in patch
Comment #5
cilefen commentedThank you for the code. This needs a merge request to proceed. It also needs a test, which could go in
core/modules/big_pipe/tests/src/Functional/BigPipeTest.phpComment #6
realgt commentedhaving issues with applying patch on 11.4.4, rerolling
Comment #7
realgt commentedattaching a test patch to check correct handling of an empty destination parameter.
Comment #8
cilefen commentedThe automated test system only triggers on merge requests, so please open one now.
Comment #10
fazal_haq commentedI reviewed MR !17062 and prepared a follow-up update based on the current main branch.
The existing change handles an empty destination value, but it must also preserve the existing handling for a completely missing destination parameter.
The update returns HTTP 400 for both cases and adds functional test coverage for:
- a missing destination
- an empty destination
The targeted BigPipe functional test and PHP coding standards pass locally. I will update the existing merge request next.
Comment #11
fazal_haq commentedUpdated MR !17062 with a follow-up fix for the empty destination error.
Previously, /big_pipe/no-js?destination= caused Drupal to attempt a redirect to an empty URL, resulting in a 500 error.
The controller now safely rejects both invalid cases with HTTP 400:
$destination = $request->query->get('destination');
if (!$request->query->has('destination') || $destination === '') {
throw new HttpException(400, 'The original location is missing.');
}
This fixes an empty destination value while preserving the existing behavior when the destination parameter is missing.
I also added functional test coverage for:
- /big_pipe/no-js — missing destination
- /big_pipe/no-js?destination= — empty destination
Both requests now return HTTP 400 and do not set the BigPipe no-JS cookie.
Required CI jobs, PHP coding standards, PHPStan, and functional tests passed.
Comment #12
fazal_haq commented