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.

Command icon 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

cruno created an issue. See original summary.

cruno’s picture

For those which also have a patch from 3111456, you'll need this separate patch file since they would collide.

deciphered made their first commit to this issue’s fork.

deciphered’s picture

Status: Active » Needs review

Pushed 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.

  • deciphered committed 48961e5b on 2.x
    test(#3611685): add kernel tests for redirect loop scenario
    

deciphered’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.