Skip to content

Commit

Permalink
VCST-1845: Indexing fails due to a null reference exception (#744)
Browse files Browse the repository at this point in the history
fix: Product index document builder fails when a product has an editorial review (description) with a null type or language code.
  • Loading branch information
OlegoO committed Sep 18, 2024
1 parent 5ff058b commit 458b95f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected virtual void IndexDescriptions(IndexDocument document, IList<Editorial
{
foreach (var review in reviews.Where(x => !string.IsNullOrEmpty(x?.Content)))
{
var descriptionField = $"description_{review.ReviewType.ToLowerInvariant()}_{review.LanguageCode.ToLowerInvariant()}";
var descriptionField = $"description_{review.ReviewType?.ToLowerInvariant() ?? "null"}_{review.LanguageCode?.ToLowerInvariant() ?? "null"}";
document.Add(new IndexDocumentField(descriptionField, review.Content, IndexDocumentFieldValueType.String) { IsRetrievable = true, IsCollection = true });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public ProductAssociationSearchService(Func<ICatalogRepository> catalogRepositor
_platformMemoryCache = platformMemoryCache;
}

public Task<ProductAssociationSearchResult> SearchProductAssociationsAsync(ProductAssociationSearchCriteria criteria)
public async Task<ProductAssociationSearchResult> SearchProductAssociationsAsync(ProductAssociationSearchCriteria criteria)
{
if (criteria == null)
{
throw new ArgumentNullException(nameof(criteria));
}

var cacheKey = CacheKey.With(GetType(), "SearchProductAssociationsAsync", criteria.GetCacheKey());
return _platformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
return await _platformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
{
cacheEntry.AddExpirationToken(AssociationSearchCacheRegion.CreateChangeToken());
var result = AbstractTypeFactory<ProductAssociationSearchResult>.TryCreateInstance();
Expand Down

0 comments on commit 458b95f

Please sign in to comment.