Bug: EPiServer.ContentDeliveryApi.Search causes an error with publishing content.

Vote:
 

Error Steps:

  • Log into the CMS Editor Interface.
  • Select any Page and make an edit.
  • Click Publish

The content will be published, but a validation error is returned with the following message:

Method not found: 'System.Collections.Generic.IEnumerable`1<!!0> EPiServer.Find.Helpers.ListExtensions.DistinctBy(System.Collections.Generic.IEnumerable`1<!!0>, System.Func`2<!!0,!!1>)'.

My Service Extension for setting up Content Delivery API is as follows:

namespace ClientName.Web.Infrastructure.ServiceExtensions;

using System;
using ClientName.Features.Common;
using EPiServer.Security;

using Microsoft.Extensions.DependencyInjection;

public static class ContentDeliveryApiServiceExtensions
{
    public static IServiceCollection AddOptimizelyDeliveryApi(this IServiceCollection serviceCollection)
    {
        // See https://docs.developers.optimizely.com/content-cloud/v1.5.0-content-delivery-api/docs/contentapi
        // This changes the root url from /api/episerver/v2.0/ to /content-api/
        serviceCollection.AddContentDeliveryApi(options =>
                         {
                             options.BaseRoute = "/content-api/";
                             options.RequiredRole = EveryoneRole.RoleName;
                             options.CorsPolicyName = ClientNameConstants.ExternalCorsPolicy;
                         });

        // See https://docs.developers.optimizely.com/content-cloud/v1.5.0-content-delivery-api/docs/contentapisearch
        // This changes the root url from /api/episerver/v2.0/ to /search-api/
        serviceCollection.AddContentSearchApi(options =>
        {
            options.BaseRoute = "/search-api/";
            options.SearchCacheDuration = TimeSpan.FromMinutes(5);
            options.RequiredRole = EveryoneRole.RoleName;
            options.MaximumSearchResults = 100;
        });

        return serviceCollection;
    }
}

Steps attempted to resolve the Issue:

  • Checked out the commit directly before the packages were installed and the bug was no longer present.
  • Checked out the commit where the packages were installed and configured as above and the bug was present
  • Tried removing CORS, Bug still manifested.
  • Removed both EPiServer.ContentDeliveryApi.Cms and EPiServer.ContentDeliveryApi.Search and commented out the code. The bug was not present.
  • Reinstated just EPiServer.ContentDeliveryApi.Cms. The bug was not present.
  • Reinstated both EPiServer.ContentDeliveryApi.Cms and EPiServer.ContentDeliveryApi.Search. The bug was present.

For now I've removed EPiServer.ContentDeliveryApi.Search from my client's project, but retained EPiServer.ContentDeliveryApi.Cms.  It's not a deal breaker for us to keep the Content Delivery Search API out of the solution as we would also include our own Search APIs tailored to the client's needs.  I would add that while the EPiServer.ContentDeliveryApi.Search package was installed, it otherwise appeared to function as expected and it is just the publishing of content that we observed as causing us an issue.

For reference, here are the other packages that were installed:

EPiServer.CloudPlatform.Cms @ 1.0.5
EPiServer.CMS @ 12.10.0
EPiServer.ContentDeliveryApi.Cms @ 3.5.0
EPiServer.ContentDeliveryApi.Search @ 3.5.0
EPiServer.Find.Cms @ 14.1.0
EPiServer.Labs.BlockEnhancements @ 1.1.1
Geta.NotFoundHandler.Optimizely @ 3.0.1
Geta.Optimizely.Categories @ 1.0.0
Geta.Optimizely.ContentTypeIcons @ 2.0.1
Geta.Optimizely.Sitemaps @ 2.0.0
MediatR @ 10.0.1
MediatR.Extensions.Microsoft.DependencyInjection @ 10.0.1
Stott.Security.Optimizely @ 0.2.0-beta
Swashbuckle.AspNetCore @ 6.4.0
Swashbuckle.AspNetCore.Annotations @ 6.4.0

#286464
Sep 01, 2022 13:44
Mark Stott - Sep 01, 2022 13:45
I tried tagging this with contentdeliveryapi.3.5.x but the tags available only include 2.x
Vote:
 

Curious -- what happens if you downgrade EPiServer.Find.Cms to 14.0.4, and keep EPiServer.ContentDeliveryApi.Search @ 3.5.0?

#286472
Sep 01, 2022 15:37
Mark Stott - Sep 01, 2022 15:46
Actually rolling EPiServer.Find.Cms back to 14.0.4 does resolve this issue as well.
Vote:
 

Daniel Issaacs, I've set your answer as the Accepted Answer because it does immediately resolve the issue and hopefully going forward that can turn around a fix for this.

For this project I have chosen to ommit the EPiServer.ContentDeliveryApi.Search package as we will have our own designed API for search.

#286475
Sep 01, 2022 15:49
Vote:
 

FYI: Fixed in Find 14.2

#287978
Sep 23, 2022 11:55
Mark Stott - Sep 23, 2022 12:33
Thank you for the heads up :)
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.