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

Comments

tepelena created an issue. See original summary.

cilefen’s picture

Priority: Critical » Major
Issue tags: +Needs steps to reproduce

Could you try to isolate the steps to reproduce? Can you get the full backtrace?

dqd’s picture

I can confirm the behaviour humbled over with testing enviroment of Drupal 8.5.4 local under php 7.2 and a little bit larger module stack and prject set to dev-stage via drupal console today. We need more info here since the chance is there, that another project instead of core comes here into the mix (redirect?).

It would be helpful if @tepelena could report some more details about the install and the last steps made before the issue occured. In our case it is hard to say, since we had 3 testers working on it and the issue occured over night in the next morning. No way out.

We have to tackle it down here further to report more but I can at least say, in the moment when you choose another path like /admin etc. the issue disappears. It only breaks on frontpage again. And yes, the home path is always the path your in at the moment. Let me test around with some Views path overrides (disabling) and the frontpage setting to see what happens.

Drupal Version
8.5.4
Web Server
Apache/2.4.33 (Debian)
PHP Version
7.2.4-1+b2
Memory limit
512M
Database Version
5.5.5-10.1.29-MariaDB-6+b1
dqd’s picture

OK, I think we have a possible starting point to discuss here. It seems this issue can occur in several ways, all pointing back to the fact that Drupal 8 relies now strongly on Views and views paths. Other modules possibly override this, or for some reason it is required to disable the default frontpage view to make other modules work correctly. In this case the default frontpage is broken and Drupal has no real good fall back in case if required and every path where you at in this moment becomes when something is broken. That's why home is unlinked in the breadcrumb and that's why clicking any home returns to the page where you are, which is a quite strange foallback behaviour, IMHO (How the issue poster has reported)

Many users will asume that D8 works in this case like D7, where /node is always the fallback if any alternative frontpage settings gets broken or set off. For search ranking the Drupal 8 way is much better. Drupal 7 maintainers had a lot work to do to get rid of all the unaliased paths and /node if that's not the frontpage. But we possibly missed to integrate some "this should not break then" scenario. Not sure.

tepelena’s picture

Thanks for the reply. This was a problem on our end. A view that was not configured properly and also ened up with the path:/ was causing the problem.

dqd’s picture

Issue summary: View changes
Priority: Major » Normal

@tepelena: thanks for taking the time to report back. It shows another example of that my concerns regarding Views path fall backs and handling are possibly not unreasoned. In this case it brings even one more question on top: what if Views paths override each other or are internal /? In the menu system we have checks against exisitng or not existing links, allowed and not allowed paths. This issue requires maybe some discussion (not sure) when free time is available, so let's keep it active.

On this regard I edited and typo corrected a little bit of the issue summary, if you don't mind, @tepelena.

Apart from that after all new informations, we can set the alert level one step more down since this is even not a "Major" from what I see here now. It is rather a question about if we want to implement alternatives checks instead of Exception errors here.

mattferderer’s picture

Ran into this issue as well on a site. Something is killing my URL.

A default fallback & warning message would be preferred over the error message in my opinion.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

micahw156’s picture

Yesterday, I added a new display to an existing view, then set the original display to be the default tab, but didn't change its URL. In initial testing, I'm pretty sure I could display and switch between tabs as expected, but I'm not 100% sure I actually tested that. Somehow the path for the initial tab was showing up as / in the views listing, rather than the path set in the view, and all attempts to access the site's homepage resulted in the error shown above, and links to HOME, etc, were indeed pointing back to the current page instead.

I think something like that might help to reproduce this in the future.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

makbay’s picture

I can confirm the case at #9 reproduces this bug. Also clicking the site logo does not go to home page and language switcher flag icons stop working on home page in this case.

alienzed’s picture

Wow, just encountered this. Creating or editing a new view should not be able to kill a site's homepage...

emilie.viau’s picture

I had the same error on log out (InvalidArgumentException), plus homepage link problems. My home link was not showing up for log out people despite it has no permission limitation. I came accross the problem by doing this :

  • Install a new instance of the latest version of Drupal 8 (keep also your old one)
  • In this new installation of Drupal, go to /admin/config/development/configuration/single/export and export the Frontpage view configuration
  • In your old site, go to admin/config/development/configuration/single/import and paste the configuration

After that, all came back to normal for me.

Yuri’s picture

#5 was caused my same issue too. Thanks!

jini osaka’s picture

@emilie.viau thanks for posting you soluition #13

I tried it but after import got the message: "There are no changes to import."

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

drakythe’s picture

Just had this happen to one of our clients. #5 was the answer for us.

We duplicated a view that had its path at `/some-path/view` and its menu settings set to Default Menu Tab with the Parent Tab set to respond at the standard `/some-path`. When we duplicated that view my team member just set a page path and changed nothing about the menu setting, only his page path was `/some-other-path`. The view kept that path, but in the View Overview list the path was displaying as `/`. We Duplicated the view page as a Block, deleted the bad page and saved the view. Everything returned to normal.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bmateus’s picture

I've just updated to 8.9.1, and this issue started. It now seems impossible for Drupal to accept a custom "front-page", and I have all the behaviour listed in #9.
Every path that we insert as a default frontpage stops working, gives WSOD.

Another issue that could be related:
I'm using some graphql views, and image urls that contain a token(itok) are now transforming the query's '&' character to '&'. This was not the behaviour before.
On direct graphql queries all remains as it was.

Updated:
I've also found I'm unable to export full configuration, blows to WSOD. Nothing appears on Drupal logs.
On my servers log, I get
(70007)The timeout specified has expired: AH01075: Error dispatching request to :, referer: https://[domain]/en/admin/config/development/configuration/full/export
Any ideas if this may be linked?

The export issue had nothing to do with it. Just needed to increase the php timeout from 60 seconds to about 200.
The other issues continue, though.

Mzambrana’s picture

I experience the same error with a Drupal that I installed the Redirect module and because of a view that had the path / homepage it did not load.
Disable the view and everything worked correctly again.

Thank you very much for the help, greetings.

cgmonroe’s picture

We had the same problem. I have found how to reproduce the error but not the full effect of always getting it for the home page.

First, create a new drupal instance on simplytest.me. No modules needed.

Create a basic page to use as a node homepage.

Set the home page to that node. (Basic Settings)

Go the Structure Views.

Edit the Content view.

Duplicate the existing view.

In the path setting, ONLY CHANGE the path to /break-it (or anything that is one level).

Save.

Go back to the view listing and you should see that the subview you created is listed as using / for a path.

Log out and you will get an Error page with the Cannot redirect message in the log.

NOTE: Strangely, if you change the URL to just / ... the original homepage will come back. But the error will happen on each logout which should let people start to debug it.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

lissy’s picture

I get the same error with a windows installation and with Linux at the hoster:

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

But logout works.

Error eccurs if i make a dublication of Admin content view:
/admin/structure/views/view/content/edit/page_1 to /admin/structure/views/view/content/edit/page_2 with al littel change.
If i delete the second page, logout works

andresisvworld’s picture

I had the same issue as Lissy. I duplicated the People view to have a list of users and users that didn't have the permissions to see what is in the view were unable to access the page.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Component: base system » views.module
Issue summary: View changes
Issue tags: +Bug Smash Initiative

I just encountered this on Drupal 9.3.something which I then updated to 9.4.2 and the problem persisted. Adding steps to reproduce, which are very similar to #21. My experience and the comments all point to this being a Views issue, therefore changing component.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

le72’s picture

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
ruuds’s picture

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.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lthomasen’s picture

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.

handkerchief’s picture

ressa’s picture

Thanks for linking to this issue @handkerchief from #3447718: Cannot redirect to an empty URL, and @lthomasen sharing your scenario.

I also ran into this after updating Menu settings in a View, in the process of not using Tabs with a "Parent menu link", after letting go of the difficult menu tab set up.

The only way I could access the front page was disabling "Global redirects" > "Enforce clean and canonical URLs" in the Redirect module.

After changing to a standard "Normal menu entry" in the View, all is well again, and I can again enforce clean and canonical URLs with the Redirect module.

mortona2k’s picture

I ran into the same as above, caused bad views tabs config.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.