InvalidArgumentException: Cannot redirect to an empty URL. in Symfony

Created on 11 May 2018, over 6 years ago
Updated 20 August 2024, 3 months ago

Problem/Motivation

Pages are not showing up (WSOD) with the following error:

The website encountered an unexpected error. Please try again later. 

InvalidArgumentException: Cannot redirect to an empty URL. in Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl() (line 86 of vendor/symfony/http-foundation/RedirectResponse.php).

I also noticed that the LOGO and HOME in the main menu do not redirect to the front page but instead they redirect to the current page.

Steps to reproduce

  1. Create a duplicate of the Content view
  2. Edit the duplicate
  3. Change the path to say /break
  4. Got to admin/structure/views and see that the path for the duplicate view is "/" not "/break"
  5. Log out and get The website encountered an unexpected error. Please try again later.

Workaround
Log back in, delete the duplicate view, and logout works without error.

Proposed resolution

TBD

Remaining tasks

Add a test
Patch
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tepelena

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡²Armenia le72 Yerevan πŸ‡¦πŸ‡²

    Had exactly the same thing today, Drupal 9.5.5.

    1. Create a duplicate of the People view (user_admin_people)
    2. Edit the duplicate
    3. Change the path to say /people-search
    4. Save the view
    5. Got to admin/structure/views and see that the path for the duplicate view is "/" not "/people-search"
    6. Log out and get "The website encountered an unexpected error. Please try again later." on homepage
  • πŸ‡³πŸ‡±Netherlands Ruuds

    I had the same issue on 9.5.8. A view had two page displays with different urls:

    ```
    /dashboard-my-applications
    /dashboard/my-applications/applications
    ```

    `/dashboard-my-applications` is presented as `/` in the views overview, but seemed to be correctly configured when editing the view. As these page displays were completely identical, removing the first one solved the issue for me.

  • πŸ‡©πŸ‡°Denmark lthomasen Aarhus

    Using Drupal 9.5.11, I had the issue with WSOD when logging out. Log message said:

    InvalidArgumentException: Cannot redirect to an empty URL. in Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl() (line 91 of C:\Users\blabla\Sites\mydrupalsite\vendor\symfony\http-foundation\RedirectResponse.php).

    When looking inside the view that caused the problem, the paths were correct, but from the /admin/structure/views page, one of the displays in my view was listed as Page (/).

    The reason the problem was created in the first place, was probably that I had messed to much with creating menu tabs in my view. Saving all page paths in the view displays as "Normal menu entry" finally cleared the missing path.

  • πŸ‡¨πŸ‡­Switzerland handkerchief

    Same issue for me as with #33: https://www.drupal.org/project/redirect/issues/3447718#comment-15736214 πŸ› Cannot redirect to an empty URL Needs review

Production build 0.71.5 2024