Unicorn added <site> breaks Sitecore on ContentDelivery roles in 10.1.2
liquid-interactive-tech opened this issue · 5 comments
The Unicorn.config file includes a node that uses a "inherits" attribute to inherit from another expected existing site titled "shell". In the OOTB 10.1.2 file: \App_Config\Sitecore\CMS.Core\Sitecore.Sites.config, the "shell" site is set to only appear in "Standalone" or "ContentManagement" sites. Consequently, Sitecore generates a 500 error page complaining that "shell" does not exist, when the Sitecore role is set to ContentManagement.
Below is the declared in Unicorn.config
<site name="unicorn"
inherits="shell"
rootPath="/unicorn/module"
enableItemLanguageFallback="false"
enableFieldLanguageFallback="false"
enforceVersionPresence="false"
/>
My first instinct is to simply add a role requirement that mimics similar ones found throughout Unicorn's configs as such:
<site name="unicorn"
inherits="shell"
rootPath="/unicorn/module"
enableItemLanguageFallback="false"
enableFieldLanguageFallback="false"
enforceVersionPresence="false"
role:require="!ContentDelivery"
/>
but wiser developers may have a better idea, or may tell me that this isn't an issue at all (as I'm surprised no one has run into this yet)
I don't know why you would deploy Unicorn configs to a role that isn't Standalone or ContentManagement is the reverse question 🙃
Generally the error you describe only appears if you deploy Unicorn configs to servers configured for the CD server role only. And the clear recommendation is, that Unicorn has no business at all being deployed to public facing server instances.
That said, if for some reason, you want to continue deploying Unicorn to CD, you would need to change this site definition role requirement. A better solution would be to just delete the Unicorn config on CD.
@cassidydotdk while I completely agree with your philosophy, the file in question, Unicorn.config, includes a comment at the top stating:
This file should be present on all environments Unicorn is present on. It is safe to leave on Content Delivery servers, as it changes no stock Sitecore configuration.
for this reason, the file should be corrected so that it can in fact, be safe to leave on Content Delivery servers
Actually it's the comment that's in error :-)
I strongly feel that it can be inferred that the philosophy that these Unicorn configuration files are intended to work in all environments out-of-the-box, based on the fact that other configuration files already include explicit "role:require" attributes, indicating that the intention is to compensate for every potential role, including ContentDelivery.
I feel that it would support future adopters better to simply add the role:require as my original post had recommended, keeping to the same mantra appearing throughout the rest of the files. The expectation that developers would need to modify the base module out-of-the-box to prevent a 500 error in a common scenario seems undesirable.
The philosophy of the Unicorn.config file is, that - like the product itself - it should work on Sitecore versions at least 8.0 through to today. role:require is not available prior to 9.x or so, I forget exactly when it was introduced by Sitecore.
There is not and has never been a "hands-off" approach to these configuration files. Some amount of tinkering was always required, whether it was to enable/disable certain files, remove certain files from deployment to specific environments, disabling the dataprovider for anything not local dev, and so on.
The fact that the top comment is misleading in Unicorn.config is an oversight from when the unicorn
site was introduced.
There are various ways people in the community goes about handling their setups. Here are a few.
- https://sitecore.stackexchange.com/a/26107/73
- https://praveenmanchanablog.wordpress.com/2020/03/02/unicorn-with-custom-rule-configurations/
You could also add a config file of your own, if you're uncomfortable modifying the supplied files. Using a patch:delete
to remove the unicorn
<site>
definition and insert your own with whatever role:require
you like.