patch

Sitecore 9.0 – Incorrect validation for media items that do not have marketing assets

Such a lovely day! We find out a Sitecore bug when migrating the content from a Sitecore 7.2 instance to a fresh Sitecore 9.0 Initial Release instance by installing Sitecore packages via Installation Wizard.

From the beginning, we can install the Sitecore packages smoothly. However, there is a Sitecore package produces the following error:

sc9bug_1

Let’s open the Sitecore log and see the error message:

ERROR System.RuntimeType One or more exceptions occurred while processing the subscribers to the ‘item:creating’ event.
Exception[1]: System.ArgumentException
Message[1]: ‘Name’ should consist only of letters, digits, dashes or underscore

Oh nice! There are some Sitecore items somehow passed the ItemNameValidation while they’re created so now we cannot install them to the new instance.

sc9bug_2

We suppose that the previous vendor disabled ItemNameValidation so they were able to create those items. As such, we implement a Sitecore patch config file to disable ItemNameValidation on the new instance in order to install the problematic Sitecore package successfully.

Once Sitecore 9 has divided configuration files into layers, we should put it into \App_Config\Environment for sure and then navigate to /sitecore/admin/showconfig.aspx for the verification

sc9bug_3

So far so good, let’s install that problematic Sitecore package again. Oh my god! We still get the above error dialog after a while. This time, we notice two things in the log file:

  1. the problematic item is a media item
  2. ERROR System.RuntimeType One or more exceptions occurred while processing the subscribers to the ‘item:creating’ event.
    Exception[1]: System.ArgumentException
    Message[1]: ‘Name’ should consist only of letters, digits, dashes or underscore
    Source[1]: Sitecore.Marketing.Core
    at Sitecore.Marketing.Core.Extensions.ConditionValidatorExtensions.IsValidAlias(ConditionValidator`1 validator)

They’re helpful for us to search out a known issue of Sitecore 9.0 https://kb.sitecore.net/articles/843095

All media items under the Media Library root are considered as marketing items. An exception occurs when trying to upload, copy, create, rename, or save an item containing any other characters in the name except for letters, digits, dashes, or underscores. Marketing operation functionality enforces marketing item name restrictions that do not take into account the ItemNameValidation setting. The ItemEventHandler class does not check if media items have marketing assets before validation.

Wow! After installing this Sitecore patch, we don’t hit that error dialog anymore. Everything looks OK.

The release was built for and tested with the following Sitecore products in bare condition (no hotfixes, patches or other customizations, unless explicitly specified):

  • Sitecore CMS 9.0 rev. 171002 (Initial Release)
  • Sitecore CMS 9.0 rev. 171219 (Update-1)
  • Sitecore CMS 9.0 rev. 180604 (Update-2)

Post step: DO NOT forget to remove DisableItemNameValidation.config after playing around with it in order to restore the Sitecore instance.

Happy Sitecore Patch!

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.