Gravatar for jnein@captechconsulting.com

Question by jnein, Jul 11, 2016 4:36 PM

Precondition failed: The parameter 'p_SearchIndex' must not be null

The exact same code is deployed on two different environments but one of them is getting the error below at line 40. It looks like it is thrown in the Coveo code so it's difficult to debug. Any suggestions?

This is using Coveo for Sitecore 4.

Thanks, John

Description: An unhandled exception occurred. 

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

Line 38:         <script type="text/javascript">
Line 39:         Coveo.$(function() {
Line 40:             CoveoForSitecore.componentsOptions = @(Html.Raw(Model.GetJavaScriptInitializationOptions()));
Line 41:         });
Line 42:         </script>
Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Jul 11, 2016 4:50 PM

First, you could check if you have any errors in your Coveo Diagnostic Page that could point us to another problem.

I would then suggest looking in your logs as it will contain more details about the error and will help us pinpoint the problem.

Gravatar for jnein@captechconsulting.com

Comment by jnein, Jul 11, 2016 5:03 PM

The diagnostic page returns all green. The log just provides the same exception details. Here is the stack trace:

Exception: System.ArgumentNullException
Message: Precondition failed: The parameter 'p_SearchIndex' must not be null
Parameter name: p_SearchIndex
Source: Coveo.Framework
   at Coveo.Framework.CNL.Precondition.NotNull(Object p_Parameter, String p_ParameterName)
   at Coveo.UI.Expressions.ExpressionBuilderFactory.CreateBoostExpressionBuilder(ISearchIndex p_SearchIndex, IRulesHelper p_RulesHelper, ISitecoreHelper p_SitecoreHelper)
   at Coveo.UI.Mvc.Models.SearchModel.get_BoostExpressions()
   at Coveo.UI.Mvc.Models.SearchModelOptionsWriter.GetObjectToSerialize(ISearchModel p_Instance)
   at Coveo.UI.Mvc.Models.BaseJavaScriptWriter`1.GetJavaScriptObject(T p_Instance)
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Jul 11, 2016 5:11 PM

By any chance, do you filter out of the index, the item that you are trying to display (Probably a search page item). Filtering items containing Coveo UI components should be avoided as it causes runtime errors like this one.

Another cause would be the context database of your website. Is the context database the same? Is there a Coveo index definition targeting this database?

1 Reply
Gravatar for jnein@captechconsulting.com

Answer by jnein, Jul 12, 2016 8:42 AM

We found the issue. There were Coveo templates that weren't published.

Ask a question