umbraco/Umbraco-CMS

Redirect url not created for urls longer than 255 characters when using SQL Server

Closed this issue ยท 8 comments

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

13.4.1

Bug summary

When renaming a content page Umbraco creates automatically a redirection that is stored in the umbracoRedirectUrl database table.

It is working fine for short urls (less than 255 characters), the redirect is visible in the "Info" ContentApp of the page and also on the Redirect management dashboard in the "Content" section.

But when renaming a content page whose url is longer than 255 characters, the redirect is not created, and an error is logged in the UmbracoLog:

Microsoft.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated in table 'UmbracoEmpty13-4-1.dbo.umbracoRedirectUrl', column 'url'. Truncated value: '/this-is-a-page-with-a-very-long-name-to-test-if-the-long-url-with-less-segments-are-also-causing-is'.
The statement has been terminated.

It is SQL Server that is impacted as the url column is created with a length of 255 characters.

Specifics

No response

Steps to reproduce

  1. Create a content page with a very long name (Save and publish it)
  2. Create a child page with a very long name too (Save and publish it)
  3. Make sure that the length of the absolute url of the page created in point 2 is longer than 255 characters
  4. Rename the content node (Save and publish it)

Expected result / actual result

After step 4, the backoffice will show the green notification that "Content published: and is visible on the website".
But the redirect url is NOT created and new entries are added to the UmbracoLog.
UmbracoLog-redirect


This item has been added to our backlog AB#43835

Hi there @singuch!

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'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

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 ๐Ÿค– ๐Ÿ™‚

The bug here seems to be the size of the url column in the umbracoRedirectUrl table.
The limit on the node name is 255 char, so, since that column is supposed to contain the absolute path of a page, by concatenating all the segments, it cannot be 255 as well.
Probably would be a good idea to put it at varchar max.

Hi @singuch , as I see the input name of content node has maxlength = 255, did you do something on devtools to change it?
Btw, I couldn't; reproduce your issue, in my case, the URL is not saved in umbracoRedirectUrl. I can still change name without error.

Content.-.localhost.-.Google.Chrome.2024-08-29.16-02-09.mp4

Could you give more details ๐Ÿค”

Ps: updated, thanks @simonech ๐Ÿ˜

Hi @NguyenThuyLan,
I didn't change anything using the devtools.

Let me explain in more details:

  1. Make sure you are using SQL Server as database and not SqlLite;
  2. In the backoffice, create a node (node1) with a name containing at least 200 characters;
  3. Save and publish node1;
  4. Under the node you just created (node1) create a child node (node2) with a name containing at least 200 characters;
  5. Save and publish node2;
  6. The url path of the child node (node2) is now at least 401 characters;
  7. At this stage all is fine, the page is working fine;
  8. Browse to the node2 page in the Frontend, and keep it open;
  9. Rename node2 to something else;
  10. Save and publish node2;

After step 10:

  • the backoffice says that content is published correctly and that is true;
  • the old url of node2 is NOT stored in the umbracoRedirectUrl database table as the url column is limited to 255 characters while the url that have to be stored is around 401 characters;
  • the UmbracoLog contains 1 exception and 1 warning saying that: "String or binary data would be truncated";
  • if you browse to the node2 page in the Frontend using its new url, it loads fine;
  • BUT if you refresh the page that you opened in step 7 (with the old url), now you get an error "404 page not found" while we expect to have a redirection from the old url to the new one.

Doing the exact same exercise with short names to keep the total length under the 255 characters limit, all is fine, even the refresh of the old url from step 7/8.

In this example I used a hierarchy of two pages with very long names to avoid having to create too many pages, but you get the same problem if you use more descendants with shorter names. As long as the deepest descendant url path is longer than 255 characters, the redirection is not working and the previous (old) url is giving a 404 in place of redirecting.

PS: small edit as I see you updated your video: In your case, if you try to open the page using the url ending with a lot of "1" it will be broken, while the one ending with "123" will work. While normally both should work.

Best regards,
Christophe

Dears,
any news on this bug?

Hey @simonech I have pulled this into my sprint and will try to get it into the 13.5 Release that is scheduled for tomorrow.

Awesome, thx @Migaroez !

Thanks @Migaroez for fixing it.