Umbraco-CMS icon indicating copy to clipboard operation
Umbraco-CMS copied to clipboard

The culture specified '' was not found in any configured sources for this service - Linux App Service Plan

Open wtct opened this issue 2 years ago • 8 comments

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

11.2.0

Bug summary

Hi Guys,

Together with @piotrbach, we have noticed an issue which occurs at every Umbraco startup and during operations performed through the ContentService in the custom threads or the Hosted Services.

We can see a lot of warnings in our logs, as below:

"The culture specified '' was not found in any configured sources for this service"

At the beginning, we were solving this warnings by adding a piece of code to each custom theads and Hosted Services, as below:

var cultrue = new CultureInfo("en");

Thread.CurrentThread.CurrentCulture = cultrue;
Thread.CurrentThread.CurrentUICulture = cultrue;

In the meantime, I have invented and implemented a tricky solution which takes into account default language configured in the backoffice.

CultureInfo.DefaultThreadCurrentCulture Property

We are just wondering if the solution available on our blog should be built-in the Umbraco or not.

We haven't found any recommendations related to the Umbraco configuration, but we have found this:

https://www.gulla.net/en/blog/change-locale-culture-for-a-linux-based-azure-webapp/

Maybe this issue could be solved by LANG setting of the Azure App Service. However, what about the default languages set in the backoffice? Should it be taken into account?

image

Specifics

No response

Steps to reproduce

  1. Prepare the Azure Linux App Service.
  2. Deploy the Umbraco.
  3. Run the Umbraco.
  4. Check warnings in the logs.
  5. Create any recurring Hosted Service.
  6. Try to create and save any changes to any node through the ContentService in the Hosted Service.

Expected result / actual result

No response

wtct avatar Mar 16 '23 18:03 wtct

Hi there @wtct!

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 :robot: :slightly_smiling_face:

github-actions[bot] avatar Mar 16 '23 18:03 github-actions[bot]

Thanks for reporting this 🐛 Wierd one indeed, this works just fine on windows app service plans, so I'm wondering unsure about whether I like the workaround in the core, or have it documented when using Linux app-service plans with Umbraco. I will bring this up to the team and get back to you (this might take a while) 👍

Zeegaan avatar Mar 20 '23 13:03 Zeegaan

Hi thanks for posting this we also host Umbraco 11 on Azure linux container apps and this error have been bugging us for some time since it's flooding the error log skewing our log rates.

We also deduced that it was related to processes on other than the main thread; the culture there is empty. Our workaround was also to manually set the thread culture in those processes.

Setting LANG in our web apps did NOT resolve the issue. Neither did setting DefaultThreadCurrent*Culture.

For context, from what I can see there are just a couple of instances in the codebase that triggers this error, for example: textService.GetAllStoredValues(Thread.CurrentThread.CurrentUICulture); which explicitly assumes a current ui culture set. Maybe the correct way of fixing this is handling an empty culture here? Or should it already be covered by DefaultThreadCurrent*Culture?

jrunestone avatar Mar 27 '23 12:03 jrunestone

Hi @jrunestone,

Thanks for letting us know that LANG setting is not working as expected.

However, please ensure that you have set the DefaultThreadCurrentCulture in the IComponent which is registered by composer and running as expected :)

I'm sure, it solved this issue perfectly :)

wtct avatar Mar 27 '23 13:03 wtct

Ran into this issue in both a docker container deployment and in a Github action test step. Setting the LANG=en_US.UTF-8 environment variable solved the issue for both.

I wouldn't expect a linux app service plan to behave any different, so might be worth double checking what value the environment variable was set to.

vsilvar avatar Nov 20 '23 18:11 vsilvar

@vsilvar As mentioned, setting the LANG variable does not work. Neither is setting the DefaultThreadCurrentCulture.

jrunestone avatar Nov 22 '23 11:11 jrunestone

Hi @vsilvar thank you for the tip! Yesterday, I experimented with the LANG setting and noticed that the warning disappeared, which was promising. However, after several deployments, it seems the issue has come back and the LANG setting is still there.

piotrbach avatar Nov 22 '23 12:11 piotrbach

Has there been any update on this?

stodolos avatar Feb 07 '24 15:02 stodolos

I am using Umbraco 13.1.1 and I am still getting this warning message showing up in the startup logs. I am running the site locally on Windows 11 with the default system culture being en-AU, and the default language being en-AU.

I have tried adding the DefaultCultureComponent as suggested, and also have set the <globalization culture ="auto" uiCulture="auto"/> in the web.config. Nothing has managed to clear this message :-( Apparently the LANG setting does not apply to Windows.

Any other suggestions?

ajatnow avatar Mar 12 '24 03:03 ajatnow

We are seeing lots of these messages on boot under Linux environment, Azure web app, running Umbraco 13.3.2. No idea how to affect it.

karlmacklin avatar Jul 01 '24 11:07 karlmacklin

Hi @karlmacklin the solution described here: https://umbracare.net/blog/how-to-use-default-language-as-default-culture-for-threads-in-umbraco/ may help you. Best, Piotr

piotrbach avatar Jul 01 '24 11:07 piotrbach

Hi @karlmacklin the solution described here: https://umbracare.net/blog/how-to-use-default-language-as-default-culture-for-threads-in-umbraco/ may help you. Best, Piotr

You were right, I added such a DefaultCultureComponent and it stopped the warnings! 👍🏼

karlmacklin avatar Jul 01 '24 13:07 karlmacklin

If such code is needed to stop Umbraco from throwing warnings, should this not be implemented in the Core?

ctolkien avatar Jul 16 '24 12:07 ctolkien