On my headless SXA 10.2 CM instance, I have a page in my tree (within a bucket) where if I try to browse for a rendering datasource, the popup does not appear, and an error appears in my logs. This happens for all renderings on the page, both in the shared layout and final layout.

browse for rendering datasource

When I click the "Browse" button, I see a POST request to /sitecore/shell/applications/field editor.aspx?mo=mini&hdl=xxxxx. This request gets a 302 response and an exception appears in the logs:

Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Nested Exception

Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
   at Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline)
   at Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic)
   at Sitecore.Web.UI.Sheer.ClientPage.RunPipelines()
   at Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e)
   at Sitecore.Shell.Applications.ContentManager.FieldEditorPage.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Nested Exception

Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.XA.Foundation.LocalDatasources
   at Sitecore.XA.Foundation.LocalDatasources.Services.DataSourceLocationsService.GetRoots(Item contextItem, String query)
   at Sitecore.XA.Foundation.LocalDatasources.Services.DataSourceLocationsService.GetDataSourceRoots(Item contextItem, Item renderingItem)
   at Sitecore.XA.Foundation.LocalDatasources.Pipelines.GetRenderingDatasource.GetDatasourceLocation.Process(GetRenderingDatasourceArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.XA.Foundation.LocalDatasources.CustomFields.FieldTypesEx.BucketInternalLink.ShowDialog(ClientPipelineArgs args)

I can only seem to reproduce the issue on one specific page item. If I duplicate that page item, I am able to browse for rendering data sources without issue. When I click the button, the POST to /sitecore/shell/applications/field editor.aspx?mo=mini&hdl=xxxxx gets a 200 response.

At first I thought this was an issue with a bad value in the renderings or final renderings, but both the problem item and the duplicated (working) item have the same exact values.

The source code for GetRoots() looks potentially problematic, but it's not clear what the exact issue is:

protected virtual Item[] GetRoots(Item contextItem, string query)
  Item[] roots = (Item[]) null;
  if (query.StartsWith("./", StringComparison.InvariantCulture) && !string.IsNullOrEmpty(contextItem.Paths.FullPath))
    if (contextItem != null)
      roots = contextItem.Axes.SelectItems(this.GetWorkingQuery(query));
    roots = this.DatabaseRepository.GetContentDatabase().SelectItems(this.GetWorkingQuery(query));
  return roots;
  • Looking at your function there might be a way that it returns null as root will not be filled in with your expected values. You first check on a contextItem path, and inside you check if the context Item is null. If contextItem is null and you try to request the path it might give issues.
    – Danny Paul
    Commented Mar 6 at 9:06
  • Correct -- that code is decompiled from SXA. It was included to show exactly where the failure is happening. The question is less about that code and more about what needs to be done to give the code what it's expecting in the first place. Commented Mar 6 at 19:13

1 Answer 1


Broadly speaking, if you get this error, it's probably because there is a mismatch between your context item's path in the database vs. the context item's path stored in the index. A reindex should fix the issue, but chances are that there is a greater issue at play.

This question and solution is similar to what was explored here. The difference is that this solution is based on SXA whereas the other was not.

The problem is caused by a custom bucketing rule which updates the bucketed item's path based on a field value in conjunction with a save event handler that performs a BucketManager.Sync() operation, but does so within the context of an EventDisabler():

using (new EventDisabler())

The deadly mistake here is the use of the EventDisabler which results in a mismatch between the item's path in the database vs. what is stored in the index (which has not been updated due to the EventDisabler).

Sitecore.XA.Foundation.LocalDatasources.Services.DataSourceLocationsService.GetRoots() is unable to resolve the context item and throws a null reference exception because it assumes that contextItem isn't null.

There are various solutions to this issue, the simplest being not to use EventDisabler when syncing buckets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.