Problem/Motivation
RedirectPathTranslatorSubscriber calls RedirectRepository::findMatchingRedirect() without handling RedirectLoopException. When a redirect chain loops, the exception bubbles up and /router/translate-path returns a 500 instead of a translation result.
The redirect module catches this exception itself (see RedirectRequestSubscriber::onKernelRequestCheckRedirect()), so regular Drupal page requests survive a bad redirect. The decoupled endpoint doesn't, and a single bad redirect entity breaks path resolution for every path whose chain passes through it. On a decoupled site the frontend suddenly can't resolve any of those URLs.
Redirect matches source paths case-insensitively, so an editor who adds /News -> /news has created a self-referencing redirect without realizing it.
Steps to reproduce
1. Install redirect and decoupled_router.
2. Add a redirect from /Example to /example .
3. Request /router/translate-path?path=/Example, or create any redirect pointing at /example and request its source path.
4. The response is a 500, with RedirectLoopException in the log.
Proposed resolution
Catch RedirectLoopException around the findMatchingRedirect() call, log a warning the same way the redirect module does, and fall through to the route-level translator so the path resolves as if no redirect existed. The source path then returns a normal lookup result (or a 404) instead of an error. Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | decoupled_router-redirect-loop-500-on-top-of-3111456-98.patch | 2.25 KB | cruno |
| decoupled_router-redirect-loop-500-2.x.patch | 1.99 KB | cruno |
Issue fork decoupled_router-3611685
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
cruno commentedFor those which also have a patch from 3111456, you'll need this separate patch file since they would collide.
Comment #5
decipheredPushed an updated patch to the issue fork that catches RedirectLoopException in RedirectPathTranslatorSubscriber, preventing 500 errors when two redirects form a cycle. Includes kernel tests covering both the loop scenario and verifying valid redirects still work alongside loops. Based on @cruno's original patch with test coverage added.
Setting to needs review.