2

Sitecore 8.2 Update 3

Im getting the following error in my logs:

40752 14:56:12 FATAL [Experience Analytics]: Failed to synchronize segments. Message: Value cannot be null.
Parameter name: item. Details:    at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
   at Sitecore.Workflows.Simple.WorkflowProvider.GetWorkflow(Item item)
   at Sitecore.ExperienceAnalytics.Core.Extensions.SegmentDefinitionExtensions.GetLanguageIndependentWorkFlowState(SegmentDefinition segmentDefinition)
   at Sitecore.ExperienceAnalytics.Client.Deployment.SyncSegmentsManager.<>c.<GetSegmentsToSynchronize>b__7_0(SegmentDefinition segmentDefinition)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Sitecore.ExperienceAnalytics.Client.Deployment.SyncSegmentsManager.GetSegmentsToSynchronize()
   at Sitecore.ExperienceAnalytics.Client.Deployment.SyncSegmentsManager.SynchronizeAllSegments()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sitecore.ExperienceAnalytics.Client.Deployment.SyncSegmentsProcessor.<Process>d__4.MoveNext()

Google does not seem to be returning useful advice this issue...

4
  • Have you tried redeploy the Marketing Definitions? Also, what is the occurrence of the error? Is it every minute? Aug 15, 2017 at 19:55
  • I deployed the marketing definitions and it still happens. It seems to happen most after I rebuild my solution. Aug 15, 2017 at 20:46
  • Please see answer below Aug 15, 2017 at 21:18
  • Did you ever get around to solve this issue? I've stumbled upon the same problem and following the steps in the post above did not help me. Nov 8, 2017 at 14:52

2 Answers 2

2

The cause of my problem had to do with the way I was implementing the Token Provider for Sitecore Services Client.

  1. I used Tokens for authenticating Sitecore Services Client
  2. There is a bug in the SigningTokenProvider - when it tries to log an error, such as the Token being expired, it fails to escape special characters correctly, the write to the log fails, and the site blows up.
  3. So, to replace the SigningTokenProvider, I had to also replace the TokenDelegatingHandler. I made an exact copy of the Sitecore's TokenDelegatingHandler, except that it instantiates my SigningTokenProvider instead of Sitecore's. I replaces Sitecore's Token DelegatingHandler with a patch file:

    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
    <settings>
      <setting name="Sitecore.Services.Token.Authorization.Enabled">
        <patch:attribute name="value">true</patch:attribute>
      </setting>
      <setting name="Sitecore.Services.SecurityPolicy">
        <patch:attribute name="value">Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy, Sitecore.Services.Infrastructure</patch:attribute>
      </setting>
    </settings>
    <api>
      <tokenSecurity>
        <signingProvider type="Sitecore.Services.Infrastructure.Sitecore.Security.SymetricKeySigningProvider, Sitecore.Services.Infrastructure.Sitecore">
          <param desc="connectionStringName">Sitecore.Services.Token.SecurityKey</param>
        </signingProvider>
      </tokenSecurity>
      <services>
        <configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
          <allowedControllers hint="list:AddController">
            <allowedController desc="EnglishController">DD.Services.Controller.SiteSpecific.XfinityPrepaidDotNet.EnglishPageRepository, DD.Services</allowedController>
            <allowedController desc="SpanishController">DD.Services.Controller.SiteSpecific.XfinityPrepaidDotNet.SpanishPageRepository, DD.Services</allowedController>
          </allowedControllers>
          <delegatingHandlers hint="list:AddDelegatingHandler" patch:instead="delegatingHandlers">
            <delegatingHandler desc="TokenDelegatingHandler">
              DD.Platform.Sc.EntityServices.TokenDelegatingHandler, DD.Platform.Sc
            </delegatingHandler>
          </delegatingHandlers>
        </configuration>
      </services>
    </api>
    </sitecore>
    </configuration>
    

The problem here is that there is another bug in Sitecore that if I log in this way, even when I log in, my user is returned as not authenticated:

http://borisbrodsky.com/sitecore/issuesolved-sitecore-isauthenticated-property-is-false-for-statlesstoken-based-authentication-in-servicesapicontroller/

So I started messing around with the validation in the TokenDelegatingHandler. What I didnt realize is that a whole bunch of the Analytics parts of Sitecore use this TokenDelegatingHandler to connect. When I changed this, I broke all sorts of analytics components, including whatever was generating that error.

  1. So, I reverted the TokenDelegatingHandler to be just a copy of Sitecore's except that it calls my SiginingTokenProvider. And my SigningTokenProvider is an exact copy of Sitecore's, except that it handles the errors correctly.

This seemed to eliminate the error. Then I had to move my custom logic that deals with the IsAuthorized problem to an AuthorizationFilterAttribute.

3
  • Good find. I'm also running into problems with invalid tokens / logging. Any idea if Sitecore have fixed this yet, and if so which version do I need to go to?
    – geedubb
    Nov 5, 2018 at 8:37
  • 1
    This was 8.2 Update (Which was very buggy in general). Sitecore accepted it as a bug so I assume its fixed, but haven't tested it. Nov 5, 2018 at 21:38
  • 1
    Sorry, 8.2 Update 3 Nov 8, 2018 at 17:25
0

Background

The cause of the error is because the item is null. Sitecore will read into the Segment table from the Sitecore Analytics database to retrieve all the segments.

All the items will then go through the method GetLanguageIndependentWorkFlowState to get the workflow. The screenshot below shows where the error is being raised (inside the implementation of the GetWorkflow).

enter image description here

The item obj1 is null. Reason: The id is not present in the Master database.

Possible Solution

  1. Populate your current Segement Table with data from a clean Sitecore reporting database or redeploy reporting definitions through the /sitecore/admin/RedeployMarketingData.aspx administrative page.

  2. Search and see which item is missing from master by taking the SegmentId (itemId) from the Segment table and then restore it from another installation. In other words, from the Segment table, copy the Segment Id and log into the Sitecore CMS and search for the ID you copied. For restoring the item, you can see if the item is present on a fresh Sitecore Instance. If yes, you can package it from the fresh instance and install it on your Sitecore Instance which is getting the error.

  3. Make sure that the default and custom dimensions are in the deploy state. If some were not, set the deploy state. This will normally deploy the segment to the Segment Table.

  4. Might be that the SegmentId is no more available in the current sitecore version or if it is a custom one, it was removed. It may be deleted from the segment table.

More information of Sitecore Segments can be found here

2
  • Sorry, I need some more details here: 1. Populate what with clean data from Sitecore reporting database, also 2) serach what? The items table in master? Restore what to where? Aug 16, 2017 at 13:49
  • @EthanSchofer please see updated points Aug 16, 2017 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.