Problem/Motivation

When submitting the form to create a new redirect and the validation does a router lookup to see if the path exists, it is possible a ParamNotConvertedException exception from the ParamConverterManager.

Steps to reproduce

  1. Create a node
  2. Copy its internal URL (eg. node/100)
  3. Delete the node
  4. Create a redirect using the deleted node internal URL (node/100) as source and anything valid as destination
  5. Save

Expected result: the redirect entity has been created
Current result: 404 error

Proposed resolution

Add a catch for the exception similar to ResourceNotFoundException catch.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 3588067-param-not-converted.patch846 bytespookmish

Issue fork redirect-3588067

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

pookmish created an issue. See original summary.

pookmish’s picture

StatusFileSize
new846 bytes

I also believe this is related to what some experience in #3057250: Validation issue on adding url redirect and maybe #3363110: Apply matching redirect even on KernelEvents::EXCEPTION.

Patch provided for those that would like it.

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

sriram_s’s picture

Status: Active » Needs review

Tested pookmish's patch from #2 locally on Drupal 10 and 11 (redirect 8.x-1.13) — reproduced the 404 and confirmed the patch fixes it.

Opened MR !203 with the patch plus a regression test.

chike’s picture

The patch fixed the issue for me. Thanks.

duaelfr’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Updated IS with steps to reproduce.
MR looks good, fixes the issue and includes tests.
Thanks a lot!

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Merged.

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.

  • berdir committed f5e4d190 on 8.x-1.x authored by sriram_s
    fix: #3588067 Adding a redirect can produce a 404 after submit
    
    By:...

Status: Fixed » Closed (fixed)

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

malcomio’s picture

We've observed a similar problem on a site running 8.x-1.13, although in our case we're not seeing any exceptions in the logs.

#3540201: Redirect module throws 404 when creating redirects with /media/* source paths mentions an issue with media URLs.

In our case, we've seen it with a custom route /document/{node}/download, where the content author was trying to redirect from the deleted node ID.

So it sounds like it might be the same issue. Will see if patching also addresses it for us.

malcomio’s picture

Yes, applying f5e4d190 as a patch to 8.x-1.13 does seem to address the problem.

Odd that the exception isn't in the logs, though...