umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.49k stars 2.69k forks source link

Custom 404 not routing on a non cultured URL #16078

Open OwainJ opened 6 months ago

OwainJ commented 6 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.2.2

Bug summary

My site has 2 cultures, and I have setup my Error404Collection like so:

"Error404Collection": [
     {
          "Culture": "default",
          "ContentXPath": "$site/errorPage[@nodeName='Page not found']"
     },
     {
          "Culture": "cy-GB",
          "ContentXPath": "$site/errorPage[@nodeName='Tudalen heb ei darganfod']"
     }
]

English is set as the default language: image

And the cultures are setup as one level paths on the homepage node: image

These are results when testing the 404 page: https://localhost:44310/en/not-a-real-page - Correctly routes to the custom English 404 page https://localhost:44310/cy/not-a-real-page - Correctly routes to the custom Welsh 404 page https://localhost:44310/not-a-real-page - Routes to the default Umbraco 404 page

Specifics

No response

Steps to reproduce

Expected result / actual result

I would expect a URL without a culture https://localhost:44310/not-a-real-page to route to the custom 404 that has been set as 404 for the default culture, instead of the the default Umbraco 404 page, in the same way that any URL without a culture uses the default variant of a node.

github-actions[bot] commented 6 months ago

Hi there @OwainJ!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

elit0451 commented 6 months ago

Hi there @OwainJ 👋

Thanks for reaching out! I can indeed reproduce this 🙂 It seems like we get an XPathException from publishedContentQuery.ContentSingleAtXPath(xpathResult) (link), which results in logging the error and returning null. This explains why we get the default Umbraco 404 page.

The behaviour is as you expect when we use Umbraco::CMS::Content::Error404Collection::ContentKey instead of ContentXPath.

I will mark this as up for grabs in case anyone wants to give it a go. 🚀

github-actions[bot] commented 6 months ago

Hi @OwainJ,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post.

Thanks muchly, from your friendly Umbraco GitHub bot :-)