Gravatar for ncipollina@captechconsulting.com

Question by ncipollina, Feb 2, 2016 1:32 PM

Content Delivery Server Precondition failed: The parameter 'p_Index' must not be null

I am getting the following error message from my Content Delivery server:

Server Error in '/' Application.

Precondition failed: The parameter 'p_Index' must not be null
Parameter name: p_Index

Description: An unhandled exception occurred. 

Exception Details: System.ArgumentNullException: Precondition failed: The parameter 'p_Index' must not be null
Parameter name: p_Index

Source Error: 


Line 17: 
Line 18:                     var currentItem = Html.Sitecore().CurrentItem.ID.ToString().Trim('}', '{').Replace("-", "");
Line 19:                     var pathField = Model.ToCoveoFieldName("Practice");
Line 20:                     queryFilters.Append(pathField + " = " + currentItem + ";");
Line 21: 

Source File: C:\Sitecore\BonSecours\Website\Views\Components\_PhysicianShowAll.cshtml    Line: 19 

Stack Trace: 


[ArgumentNullException: Precondition failed: The parameter 'p_Index' must not be null
Parameter name: p_Index]
   Coveo.Framework.CNL.Precondition.NotNull(Object p_Parameter, String p_ParameterName) +210
   Coveo.UI.Helpers.SitecoreHelper.GetFieldNameTranslator(ISearchIndex p_Index) +100
   Coveo.UI.Helpers.FieldHelper.ToCoveoFieldName(IIndexable p_Indexable, String p_SitecoreField, Boolean p_UsePrefix) +264
   ASP._Page_Views_Components__PhysicianShowAll_cshtml.Execute() in C:\Sitecore\BonSecours\Website\Views\Components\_PhysicianShowAll.cshtml:19
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +125
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +147
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +353

[InvalidOperationException: Error while rendering view: '/Views/Components/_PhysicianShowAll.cshtml' (model: 'Coveo.UI.Mvc.Models.SearchModel, Coveo.UIBase').
]
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +906
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +27
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +62
   (Object , Object[] ) +83
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +445
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
   Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +192
   (Object , Object[] ) +83
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +445
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
   Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +323
   ASP._Page_Views_Pages__PracticeDetail_cshtml.Execute() in C:\Sitecore\BonSecours\Website\Views\Pages\_PracticeDetail.cshtml:64
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +125
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +147
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +353

[InvalidOperationException: Error while rendering view: '/Views/Pages/_PracticeDetail.cshtml' (model: 'Bon.Secours.Framework.Models.ReferenceData.PracticeModel, Bon.Secours.Framework').
]
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +906
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +27
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +62
   (Object , Object[] ) +83
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +445
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
   Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +192
   (Object , Object[] ) +83
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +445
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
   Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +323
   ASP._Page_Views_Layouts_BaseLayout_cshtml.Execute() in C:\Sitecore\BonSecours\Website\Views\Layouts\BaseLayout.cshtml:39
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +125
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +147
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +353

[InvalidOperationException: Error while rendering view: '/Views/Layouts/BaseLayout.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc').
]
   Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +906
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +27
   Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +62
   (Object , Object[] ) +83
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +445
   Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
   Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer) +294
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +879

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274

I have followed the instructions for setting Coveo up for Sitecore in a Content Mangement/Content Delivery server and I'm getting this error. We have created several views that are based on Coveo components and this is the only one that is having this issue. The same page shows fine in the Content Management server web instance. Any suggestions as to what may be wrong?

2 Replies
Gravatar for ncipollina@captechconsulting.com

Answer by ncipollina, Feb 3, 2016 3:19 PM

My last comment was my issue. Since I was searching for the item in a bucket using the coveo index, it was returning the item with the "pubweb" database. The "web" database was the sitecore context database so there was a mismatch. In my processor that did the search for the item, I changed it so that it would get the item from the current context database using the ID. This solved my issue.

Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Feb 2, 2016 2:07 PM

Hi,

Is it possible that the item in which this view is used is excluded from the Coveo indexes by:

  • A modification to the <Root> of the index crawler in the Coveo.SearchProvider.config file,
  • An ExcludeTemplate filter
  • An inbound filter
  • Some other pipeline or filter mecanism

This kind of error is often the result of too aggressive filtering at index time. Coveo for Sitecore code needs the items in which UI components will be used to be indexed by CES.

I recommend you to try to find the item you tried to load in the Coveo Index Browser:

  1. Open the CES Administration Tool (default is http://{CES-Hostname}:8081 )
  2. Navigate to the Content > Index Browser section
  3. Select the "Sitecore Search Provider" collection in the "Collection" facet on the left.
  4. Select the source that should be used by your CD server.
  5. Enter search terms to find the item in the search box.

If you are unable to find the item in the CD source but are able to find it in the "Master" or "Web" source, it means that there's a different filter on your CD source that should be removed. If you are able to find the item in all the sources, the problem is probably not the one I just described.

I hope this helps. Keep me updated on the results,

Jeff

Gravatar for ncipollina@captechconsulting.com

Comment by ncipollina, Feb 2, 2016 2:42 PM

Hi Jeff,

I went ahead and followed your steps and I definitely find the item in the index but I don't think that is what is going on here. This is actually failing on the line of code where we are trying to get the Coveo Field name. This is the line of code that is failing:

var pathField = Model.ToCoveoFieldName("Practice");

At this point, I'm not even sure what the context is. As far as the root is concerned, my index is defined as follows:

<Root>/sitecore</Root>

So I'm not changing the root on the index from the default value.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 2, 2016 3:10 PM

Hi,

I'll explain how Model.ToCoveoFieldName(string) is working and maybe it will help us understand what is happening in your instance.

Model.ToCoveoFieldName(string) calls FieldHelper.ToCoveoFieldName(string) which calls FieldHelper.ToCoveoFieldName(IIndexable, string) with SitecoreUtilities.GetCurrentIndexable() as the first parameter. This IIndexable object is the Sitecore context item. If the current context item is null or its database is not the same as the Sitecore context database, then, the root item of the Sitecore context database is used (often /sitecore).

Then, the IIndexable object is used to find a Coveo index that indexes it and a IFieldNameTranslator object is created from that index:

ISearchIndex index = m_SitecoreHelper.GetSearchIndex(p_Indexable);
IFieldNameTranslator translator = m_SitecoreHelper.GetFieldNameTranslator(index);

m_SitecoreHelper.GetSearchIndex(p_Indexable) verifies the IIndexable object is not null and returns the first Coveo index able to index this item by running the coveoGetContextCoveoIndex pipeline. If this pipeline returns a non empty string, Coveo for Sitecore asks Sitecore to return the index object from the ContentSearchManager.

In your case, m_SitecoreHelper.GetSearchIndex(p_Indexable) is returning null and the next call to get the field name translator is throwing.

This leads me to the following checks:

  • Verify your coveoGetContextCoveoIndex pipelines on your CM/CDs to see if they are different.
  • Verify your Coveo indexes configuration on your CD. Check the database name they index, verify the spelling against the database nodes. Check the database connection strings too maybe.

If this doesn't help, I suggest you to open a support ticket at https://coveocommunity.force.com/s/support

Please include a link to this question, your Sitecore, Coveo for Sitecore, Coveo Search API and CES versions including the revision/build numbers, a copy of the ShowConfig.aspx page result on your CD server, a copy of your CD server Coveo.SearchProvider.config file and your recent logs.

Thank you.

Gravatar for ncipollina@captechconsulting.com

Comment by ncipollina, Feb 3, 2016 2:48 PM

Thanks for explaining that. We have two different pages that have similar renderings on them. I added the following code to both pages:

var sitecoreHelper = new SitecoreHelper();
var fieldHelper = new FieldHelper(sitecoreHelper);
var itemAsIndexable = (IIndexable)(SitecoreIndexableItem)Sitecore.Context.Item;
var index = sitecoreHelper.GetSearchIndex(itemAsIndexable);

In both cases itemAsIndexable is not null, but GetSearchIndex doesn't work on the page I'm having issues with. The only real difference that I can think of off the top of my head is that on the page that is working, the item is not a bucket. In the case where it isn't working the item is a bucket item. Does that make a difference. I've also confirmed that the item is definitely in the index in question. Why would it not be able to find the index for the item?

Gravatar for ncipollina@captechconsulting.com

Comment by ncipollina, Feb 3, 2016 3:02 PM

A little more information. I also added a statement to see what the item's database is and what the sitecore context database is. In the case of my bucket item they are different. The sitecore context database is web, my item's database is pubweb. I think this is because the item is a bucket item, I have to search in the coveo index to find the item, then set the Sitecore.Context.Item to the indexable item that I've found using the GetItem() method. My guess is that since it's returning from Coveo, it's returning the item from the pubweb database.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 3, 2016 3:31 PM

At this point, we will need your configuration files and ShowConfig.aspx result to continue troubleshooting. As I said earlier, I suggest you to open a support ticket at https://coveocommunity.force.com/s/support

Thank you.

Ask a question