Infocaster/UrlTracker

Long URLs truncate error

JamiePattison opened this issue ยท 5 comments

Describe the bug
Using version: [10.0.0]
A clear and concise description of what the bug is.

To Reproduce
Create a new Umbraco page, called test.
Send in a query which contains a lengthy string (maybe more than 255 characters)
In a browser type http://localhost/test?sp=abcdef......
Press enter and an error is logged
SqlException (0x80131904): String or binary data would be truncated in table 'database.urlTrackerReferrer', column 'url'.

Expected behavior
Ignore that page.

Attempted to add ["test"] to UrlTracker:BlockedUrlsList under the config but this doesnt do anything.

Hi @JamiePattison ! Thank you very much for reaching out! I'll go investigate your issue. Looks like it's attempting to register a 404 Not Found response, but if the page exists, then that shouldn't be happening. I should get back to you within about 2 days

@D-Inventor Thank you!! Just to confirm, the page has a different query passed to it each time so if the logic is based on the page name and the long query then im pretty certain it wont ever exist :-) as the query passed to the page can randomly change.

Thank you for clarifying ๐Ÿ™‚

I've done a small test and I find that on existing Umbraco pages, this error does not occur. It does happen on urls that give a 404 response, but not on the 'urlTrackerReferrer' table. Can you give me some more context on the nature of this url that you use? Does this url redirect to a different page or do you navigate away from this page with some button or link? It's the "referrer" part here that intrigues me and it suggests that this "test" page is not the page that you actually visit, but the page that you navigate away from, which also explains why the 'BlockedUrlsList' didn't work for you.

Nevertheless, if you need to exclude certain pages based on the httpcontext, you can always make a filter on the 404 tracker like this:

public class CustomClientErrorFilter : IClientErrorFilter
{
    public CustomClientErrorFilter(/*Use dependency injection to get any dependency you need*/)
    { }

    public ValueTask<bool> EvaluateCandidateAsync(HttpContext context)
    {
        if (CurrentRequestIsNotValidAccordingToCustomLogic(context))
        {
            // ๐Ÿ‘‡ Return false to stop the current request from being registered as client error
            return new ValueTask<bool>(false);
        }

        // ๐Ÿ‘‡ Return true to continue client error tracking
        return new ValueTask<bool>(true);
    }
}

public class CustomClientErrorFilterComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        // ๐Ÿ‘‡ Register the client error filter using a composer
        builder.ClientErrorFilters()
            .Append<CustomClientErrorFilter>();
    }
}
mrflo commented

I'm facing the same error "String or binary data would be truncated" but without the table name and on save and publish on the home node. In my case urls of descendants nodes might be quite long. I've updated to VARCHAR(255) all Url fields in all tables to VARCHAR(400) and it's now working...

Version 10.3.3 has been released with a fix for this issue. We've updated the url columns so as to support urls with a length up to 2083 characters.