Coveo for Sitecore 5 is now available!

Sitecore.ContentSearch.SitecoreItemCrawler.IsAncestorOf(Item item) error

Symptoms

You see this message in your Sitecore logs :

6048 22:49:54 ERROR Application error.
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.ContentSearch
at Sitecore.ContentSearch.SitecoreItemCrawler.IsAncestorOf(Item item)
at Sitecore.ContentSearch.SitecoreItemCrawler.IsExcludedFromIndex(SitecoreIndexableItem indexable, Boolean checkLocation)
at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.<>c\_\_DisplayClass9.<GetContextIndex>b\_\_3(<>f\_\_AnonymousType1\`2 <>h\_\_TransparentIdentifier0)
...

In addition, http://<YourSitecoreInstance>/coveo/rest is returning 500 errors all of a sudden.

Environment

  • Coveo for Sitecore 863+

  • Error Message

  • REST API

Explanation

This error can occur if a new index/crawler is added to the web.config and if the root of that item is only in the master database (i.e., it is not yet published in the web database). This is also true if a crawler root is modified to an item that is not yet in the web database.

The reason is that when Sitecore tries to fetch the index for an item, it lists all the crawlers and filters out the ones that are not supposed to crawl the item. The method is fragile as it doesn’t do null checks. Sitecore seems aware of the issues in that method and has provided a workaround as we can see in StackOverflow (see links below).

Resolution

You need to fix the new component that you introduced. Follow the links below for more details on how to do so.