Troubleshooting Sitecore XP 9.2 - Experience Analytics error - Exception System.ArgumentNullException: typeKey should not be null.

It isn't uncommon when you open up the Experience Analytics dashboard hoping to see some beautiful graphs and charts showing analytics data and boom! It welcomes you with the ugly red lines:

I am usually very calm when dealing with errors in this dashboard because I have seen many root causes and found the fixes for them. Usually they are caused by certificate issues here or there.

But this time looking at the log in the website, it shows a brand new error:

30240 10:24:37 ERROR [Sitecore Services]: HTTP GET
URL http://mydomain.dev.local/sitecore/api/ao/aggregates/all/0751EFD8564F40A38083EF5C6E194247/-3191897772735422194?&dateGrouping=by-auto&&dateFrom=18-01-2020&dateTo=16-04-2020&keyGrouping=by-key

Exception System.ArgumentNullException: typeKey should not be null.
Parameter name: typeKey
at Sitecore.Framework.Conditions.RequiresValidator`1.ThrowExceptionCore(String condition, String additionalMessage, ConstraintViolationType type)
at Sitecore.Framework.Conditions.Throw.ValueShouldNotBeNull[T](ConditionValidator`1 validator, String conditionDescription)
at Sitecore.Framework.Conditions.ValidatorExtensions.IsNotNull[T](ConditionValidator`1 validator)
at Sitecore.Xdb.ReferenceData.Core.DefinitionCriteria..ctor(String moniker, DefinitionTypeKey typeKey)
at Sitecore.ExperienceAnalytics.Core.Repositories.ReferenceData.ReferenceDataSegmentReader.Get(String moniker, DefinitionTypeKey typeKey, NameValueCollection readingPreferences)
at Sitecore.ExperienceAnalytics.Core.Repositories.ReferenceData.ReferenceDataSegmentReader.Get(IEnumerable`1 keys, NameValueCollection readingPreferences)
at Sitecore.ExperienceAnalytics.Aggregation.Repositories.AggregationSegmentReader.Get(IEnumerable`1 keys, NameValueCollection readingPreferences)
at Sitecore.ExperienceAnalytics.Api.RequestTypeResolver.GetReportSegments()
at Sitecore.ExperienceAnalytics.Api.RequestTypeResolver.GetRequestType()
at Sitecore.ExperienceAnalytics.Api.Http.ModelBinding.ReportQueryModelBinder.GetModelFromBindingContext(HttpActionContext actionContext, ModelBindingContext bindingContext)
at Sitecore.ExperienceAnalytics.Api.Http.ModelBinding.ReportQueryModelBinder.BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
at System.Web.Http.ModelBinding.ModelBinderParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)

Unable to find an answer on the internet, I decided to use dotPeek to figure out what's wrong.
At first it seems the error come from the ReferenceDataSegmentReader, it is getting the definitions with the type 'sitecore.exa.segment':



Suspecting that the definitions are empty, I ran the below script in Reference database:

SELECT b.ID, Convert(varchar(max), b.Data) Data
FROM [vpbank_ReferenceData].[xdb_refdata].[DefinitionTypes] a
inner join [vpbank_ReferenceData].[xdb_refdata].[Definitions] b
on a.ID = b.TypeID where a.Name = 'sitecore.exa.segment'

Now, if at this point, you do not find any records from the above query, you must redeploy the definitions:


However it returns 66 rows, meaning my problem does not come from here. I started to panic and seek help from Sitecore Support.

They threw me a lifesaver:
After reviewing xConnect logs, it seems like there is sql connection issue with your ReferenceData database.
ERROR An error occurred while communicating with the SQL Server
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'referencedatauser'.
Could you please check if the credentials are correctly configured in the ConnectionStrings.config in your xConnect instance? The ArgumentNullException could happen when data is not retrievable from the ReferenceData database.

Fix the login credentials and the errors are gone.

Lesson learned: Never trust the error in website's log regarding analytics issues. They are often obscured by the xConnect. Check the xConnect's log instead!

Happy Sitecoring!

Comments

Popular posts from this blog

[Azure App Service] Error Rendering Sitecore.JavaScriptServices.ViewEngine.Presentation.JsLayoutRenderer: Value cannot be null. Parameter name: address

Sitecore XP/XC 10 installation fails at WebDeploy task