Cannot redirect to an empty URL

Created on 16 May 2024, about 1 month ago
Updated 30 May 2024, 28 days ago

For some reason, one of my pages is getting this error:

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 /vendor/symfony/http-foundation/RedirectResponse.php).
Drupal\Component\HttpFoundation\SecuredRedirectResponse->setTargetUrl() (Line: 39)
Symfony\Component\HttpFoundation\RedirectResponse->__construct() (Line: 26)
Drupal\Core\Routing\TrustedRedirectResponse->__construct() (Line: 166)
Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 157)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I deleted the one redirect that showed up in node edit. I tried disabling "Enforce clean and canonical URLs" and cleared cache, but the page still has the white screen error.

🐛 Bug report
Status

Active

Version

1.9

Component

Code

Created by

🇺🇸United States joshuasosa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joshuasosa
  • 🇺🇸United States joshuasosa

    Attached is a patch that just checks if the resulting URL is empty before performing the redirect response. This fixes the issue for me, but it could also be good to figure out how to prevent the issue from happening in the first place.

  • 🇮🇳India ameymudras

    @joshuasosa thanks for the patch. I checked the code and looks like we are fixing the symptom rather than the root cause. The redirect URL is a required field and hence its absolute URL shouldn't be empty in the first place. It would be helpful if you could provide exact testing steps here

  • 🇺🇸United States joshuasosa

    Thanks for reviewing! I'm not currently sure about steps to reproduce. The issue I encountered might stem from a migration from D7 to D9/10.

  • 🇺🇸United States ngreenup

    I have a new drupal 10 site that I works great and has a views page set as the home page. When i install the redirect module the home break breaks with this same error. In addition the home page links in breadcrumbs and admin toolbar dont have a link or go the wrong place. If I uninstall redirect module it all works as expected.

    Let me know if there is anything further I can test to help you discover the issue.

Production build 0.69.0 2024