As time goes on, something I’ve noticed is that as Sitecore evolves it is taking a greater reliance on search integration – making things like Solr ever more important. And that leads to an exciting new set of issues you come across if, for some reason, your search service is not available.
I wasted some perfectly good development time recently when some of my renderings vanished from published pages, thanks to this.
My initial confusion
I was working on a “gated content” feature for a client’s site. I’d been doing some back-end work on a rendering for this, where editors were able to select an Experience Form for data capture, and the download that website user’s would receive for completing it. I’d got all the back-end code for this working happily the a day or two before, and was planning on spending another hour or so on some refactoring before merging the code. But when I fired up my dev site to get to work on this, my gated content component had vanished:
Confused, I checked presentation details. I checked I was still looking at the right source branch. I checked the “web” database, to make sure I’d published everything. And, I began to worry that my success from the night before had been some sort of very real-feeling dream.
Searching for an answer
I kept digging, to try and work out what was happening, and came across this in the site logs:
13184 07:14:12 WARN '{183620B4-31CB-4FB5-9DB5-9D67414E7104}' is not valid datasource for web or user does not have permissions to access.
13184 07:14:12 WARN Failed to execute datasource query System.NullReferenceException: Object reference not set to an instance of an object.
at Sitecore.ContentSearch.SitecoreItemCrawler.IsExcludedFromIndex(SitecoreIndexableItem indexable, Boolean checkLocation)
at Sitecore.ContentSearch.SitecoreItemCrawler.GetContextIndexRanking(IIndexable indexable)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.Min(IEnumerable`1 source)
at Sitecore.ContentSearch.AbstractSearchIndex.Sitecore.ContentSearch.Pipelines.GetContextIndex.IContextIndexRankable.GetContextIndexRanking(IIndexable indexable)
at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.<>c__DisplayClass6_0.<RankContextIndexes>b__0(ISearchIndex i)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.GetContextIndex(IIndexable indexable, GetContextIndexArgs args)
at Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex.Process(GetContextIndexArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Abstractions.CorePipelineWrapper.Run(String pipelineName, PipelineArgs args)
at Sitecore.ContentSearch.Pipelines.GetContextIndex.GetContextIndexPipeline.Run(ICorePipeline pipeline, GetContextIndexArgs args)
at Sitecore.Mvc.ExperienceEditor.DatasourceValidator.DatasourceValidator.IsDatasourceValid(String dataSource, Database database)
My first thought on reading that top line was that I’d done something odd to my datasource item by mistake. So I re-checked that this existed, that my component pointed to it correctly, that it had the right template for my rendering, and that it didn’t have any unexpected security applied. But all of those were correct.
Which lead me to looking at the second part of the error – the NullReferenceException
.
Skimming the log, I’d seen “null reference” and assumed that my code was throwing because the datasource item wasn’t accessible. But when I read that log entry a second time I realised that actually my code was not mentioned in that stack trace. It’s all Sitecore code, and it’s talking about the ContentSearch APIs and “datasource queries”.
Now I knew there was no query in the datasource set on my component, as it just used the ID of the target item. But this started me thinking about search indexes – which were provided by Solr in this case. So I tried browsing to the Solr UI to check that it was happy, and bingo:
No Solr. I had it installed as an NSSM service, so checking the Services admin tool in Windows:
I restarted that service, and refreshed my page – no difference. But after an iisreset:
Bingo! My work was back.
At this point I remembered I’d stopped a load of “non-essential” services the night before to make my laptop battery last for a long train journey…
Conclusions
More and more bits of Sitecore are relying on Solr these days. The xConnect services need it. The Experience Forms editing UI needs it. And it seems there is also a datasource validation pipeline component which also relies on it.
So you need to make sure it’s up and running if you don’t want to feel as silly as I did…
Top comments (0)