During the publishing of Sitecore templates that have sub-items and related items, a System.ArgumentException error might occur:
[Error] Error in the VariantsValidationTargetProducerThis issue affects Sitecore Publishing Service 2.2 Update-1 - 3.1 Update-2, and 4.0.0.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Sitecore.Framework.Publishing.ManifestCalculation.VariantsValidationTargetProducer.CandidatePromotionContext.CalculatePublishActions(Boolean replaceUnmodifedVariants)
at Sitecore.Framework.Publishing.ManifestCalculation.VariantsValidationTargetProducer.Emit(CandidatePromotionContext context)
at Sitecore.Framework.Publishing.ManifestCalculation.VariantsValidationTargetProducer.ProcessCandidate(CandidatePromotionContext context)
at Sitecore.Framework.Publishing.ManifestCalculation.VariantsValidationTargetProducer.<Initialize>b__12_0(IList`1 ctxs)
To resolve the issue, consider one of the following options:
https://github.com/SitecoreSupport/Sitecore.Support.40925/releases.