I'm having this issue with Coveo only in staging where a 500 error is returned instead of seeing search results in the page.
The Sitecore version we're running is 10.3 and the Coveo package installed is version 5.7 . Peeking at the code, there is no other place that checks for the API key until this point. So it seems that the API key is just not passed in.
Oddly there are no logs in the server stating why this API key is missing. Just that it is 'Missing'
Exception: System.ArgumentException
Message: Precondition failed: The parameter 'p_ApiKey' must not be an empty string
Parameter name: p_ApiKey
Source: Coveo.Framework
at Coveo.Framework.CNL.Precondition.RaiseArgumentException(String p_Message, String p_ParameterName)
at Coveo.Framework.CNL.Precondition.NotEmpty(String p_Parameter, String p_ParameterName)
at Coveo.CloudPlatformClientBase.Communication.CloudPlatformHttpClientFactory.CreateAuthorizedJsonHttpClient(String p_ApiKey)
at Coveo.CloudPlatformClientBase.CloudPlatformClient..ctor(CloudPlatformConfiguration p_Configuration, ICloudPlatformHttpClientFactory p_CloudPlatformHttpClientFactory, IPipelineRunnerHandler p_PipelineRunnerHandler, ISerializer p_Serializer, ICoveoSettings p_CoveoSettings, IStaticTTLCacheFactory`2 p_StaticTTLCacheFactory, ICriticalExceptionHandler p_CriticalExceptionHandler)
at Coveo.CloudPlatformClientBase.CloudPlatformClient..ctor(CloudPlatformConfiguration p_Configuration)
at Coveo.CloudPlatformClientBase.Communication.CloudPlatformClientFactory.GetCloudPlatformClient(CloudPlatformConfiguration p_Configuration)
at Coveo.SearchProvider.Licensing.CloudLicenseRetriever.GetCloudLicense()
at Coveo.SearchProvider.Licensing.CloudLicenseRetriever.GetLicense(Boolean p_ForceRetrieve)
at Coveo.SearchProvider.Licensing.Cloud.LicenseRetriever.GetLicense(Boolean p_ForceRetrieve)
at Coveo.SearchProvider.Licensing.LicenseManager.RetrieveLicense(Boolean p_ForceUpdate)
at Coveo.SearchProvider.Licensing.LicenseManager.EnsureValidLicense()
at Coveo.SearchProvider.Licensing.LicenseManager.GetLicenseInformation()
at Coveo.SearchProvider.Rest.SitecoreRestHttpHandler.InitializeLicenseSettings()
at Coveo.SearchProvider.Rest.SitecoreRestHttpHandler.OnInitializeSettings()
at Coveo.Search.Api.Proxy.ProxyHttpHandler.OnInitialize()
at Coveo.Search.Api.Proxy.ProxyHttpHandler.EnsureInitialized()
at Coveo.Search.Api.Proxy.ProxyHttpHandler.ProcessRequest(IHttpContext p_Context)
at Coveo.SearchProvider.Rest.SitecoreRestHttpHandlerDispatcher.ProcessRequest(HttpContext p_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)
We are hosting this instance of Sitecore on an Azure app service. It seems to be just this application causing this issue. Other local instances seem to work fine.
We have check the Application Gateway and there is no reason for the app service to be blocked from there. As it's all in the same group.
After looking around and not seeing any logs, There was a iframe option header included in the web config. And it seemed that this was blocking coveo from communicating to its own api even though the api is of the same domain. Seems a little confusing but internally it must use an iframe to send off a request to coveo and that process would be getting blocked.
So go navigate your web config file and make sure that you do not have a header similar to this blocking your requests.
Hope it helps someone.