skybrud / Skybrud.Umbraco.Redirects

Redirects manager for Umbraco.
https://packages.limbo.works/skybrud.umbraco.redirects/
MIT License
38 stars 43 forks source link

String reference not set - errors #164

Open FransLammers opened 2 years ago

FransLammers commented 2 years ago

Hi @abjerner

We are using the Redirects package 2.1.v in an Umbraco 8.18.5 project. The project has multiple languages in multiple domains. When we add a redirect for All sites everything works fine, but since there have been redirects added for specific sites we get a lot of errors in the log:

System.ArgumentNullException: String reference not set to an instance of a String.
Parameter name: name
   at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
   at Skybrud.Umbraco.Redirects.Domains.DomainUtils.<>c.<FindDomainForUri>b__0_0(IDomain x)

Is there anything we can do to prevent this, or is it a bug in Redirect?

abjerner commented 1 year ago

Hi @FransLammers

I missed this issue, so sorry for the late reply.

If I remember correctly, I based the method of similar logic in Umbraco own source code. It seems that the method may fail if a culture isn't specified for the node:

image

But I'm running a site where there isn't specified a culture at the root node level either, but this still works fine. So currently I'm not sure why it fails in your case.

The Umbraco 8 package isn't my top priority anymore, but I'll see if I can find some time to look more into this issue 😉

abjerner commented 1 year ago

Maybe going our on a limb, but could you try checking the umbracoDomains in the database?

The domainDefaultLanguage column references languages in the umbracoLanguage table. Does all the domainDefaultLanguage IDs also exist as languages in the umbracoLanguage table?

I think if you have deleted a language, and the umbracoDomains table is still referencing the language, you could see errors like the one you shared. Can you confirm whether this is the case?