Content database 'master' not found on a content delivery server

In this article

Symptoms

When deploying Coveo for Sitecore on a content delivery instance, you get the following error:

Content database 'master' not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Content database 'master' not found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Content database 'master' not found.]
   Sitecore.Context.get_ContentDatabase() +488
   Coveo.Framework.Utils.SitecoreContextWrapper.GetCurrentDatabaseName() +31
   Coveo.SearchProvider.Utils.CoveoIndexUtilities.GetDefaultCoveoIndex(ISitecoreContext p_SitecoreContext, ICoveoIndexFetcher p_CoveoIndexFetcher) +216
   Coveo.SearchProvider.Rest.SitecoreRestHttpHandlerDispatcher.ProcessRequest(HttpContext p_Context) +169
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +866
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +91

Cause

The coveoapi site is missing a patch specific to CD environments.

Resolution

Immediate steps

In the <SITECORE_INSTANCE_ROOT>\App_Config\Modules\Coveo\Coveo.Authentication.config file, change the following line:

<site patch:before="*[1]" name="coveoapi" virtualFolder="/coveo" physicalFolder="/coveo" enableTracking="false" content="master" domain="sitecore" set:loginPage="$(loginPath)shell/SitecoreIdentityServer" />

to this:

<site patch:before="*[1]" name="coveoapi" virtualFolder="/coveo" physicalFolder="/coveo" enableTracking="false" content="master" domain="sitecore" set:loginPage="$(loginPath)shell/SitecoreIdentityServer">
    <patch:attribute role:require="ContentDelivery" name="content">web</patch:attribute>
</site>

Final steps

This issue is resolved in the May 17, 2019 release of Coveo for Sitecore. Upgrade Coveo for Sitecore to the May 17, 2019 release.