Jeremy Davis
Jeremy Davis
Sitecore, C# and web development
Article printed from:

I'm sure my renderings were there yesterday?

Published 03 September 2018
Updated 12 September 2018
Sitecore Solr Bug ~2 min. read

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.

Updated to add: In the comments, Sandip points out that Sitecore have a patch for this issue. You can resolve it in v9 Update 1 with Sitecore's patch, and the fix is rolled into update 2.

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:

Missing Renderings

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 compoinent 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

No Solr. I had it installed as an NSSM service, so checking the Services admin tool in Windows:

Service Stopped

I restarted that service, and refreshed my page – no difference. But after an iisreset:

Rendering Back

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...

epic facepalm


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...

↑ Back to top