-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Describe the bug
We've likely discovered a bug in resource management.
Occassionally, the ContentBasePath inside ResourceManagement is set to '/' instead of tenant prefix or an empty string.
This results in 404 errors for all resources — scripts, links, CSS. I attempted to debug this, but since it happens only sporadically and we haven’t found any pattern yet, it’s unclear what exactly causes it.
My current hypothesis is that the ShellScope.Context in ModularTenantRouterMiddlewares being switched to the Default tenant after entering the if-condition. The default tenant has empty RequestUrlPrefix which might cause the incorrect PathBase = '/'.
If this is the case, it would imply that the value inside AsyncLocal is being changed unexpectedly, possibly by another thread or due to some async behavior.
The bigger issue is that even though this happens only occasionally, resource management options are initialized only at startup. So once this occurs, the admin theme breaks and the entire project needs a restart.
Do you have any ideas on what else we could inspect or how we might reliably reproduce this?
Possible solution:
It seems that simply modifying the assignment in ResourceManagementOptionsConfiguration
from
options.ContentBasePath = _pathBase.Value;
to
options.ContentBasePath = "/" + shellContext.Settings.RequestUrlPrefix;
could be a workaround.
Orchard Core version
2.2
(it does not happen on similiar solutions on 1.8.4)
To Reproduce
unknown - happens on solutions with multiple tenants, rest apis
Expected behavior
Logs and screenshots
I replaced ResourceManagementOptionsConfiguration with a custom implementation to capture this situation:
After the issue occurred, the logs contain:
2025-11-27 00:51:30Z|||PuxOverride.Resources.ResourceManagementOptionsConfiguration|ERR|Mismatch / between ResourceManagementOptionsConfiguration PathBase '/' and Shell RequestUrlPrefix ''|
RequestUrlPrefix is correct because this is the Default tenant.
However, what's strange is that the tenant name is missing from the log.
It should be something like:
2025-11-27 00:51:30Z||Default|....