umbraco / Umbraco.Commerce.Deploy

MIT License
0 stars 2 forks source link

Selecting a Tax Class and Saving/Save and Publish throws a System.AggregateException in Umbraco12 #3

Closed robertjf closed 11 months ago

robertjf commented 11 months ago

We upgraded from Umbraco 10 to 12.2 with Umbraco.Commerce 10 -> 12 and now when we attempt to save a Product with the Tax Class StoreEntityPicker, we get the following exception thrown on Save and Publish (Or Save):

An error occurred
One or more errors occurred. (Cannot cast dataType configuration, of type StoreEntityPickerConfiguration, to Dictionary`2.)

Exception Details
System.AggregateException, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: One or more errors occurred. (Cannot cast dataType configuration, of type StoreEntityPickerConfiguration, to Dictionary`2.)
Stacktrace
at Umbraco.Cms.Infrastructure.Scoping.Scope.TryFinally(Action[] actions)
   at Umbraco.Cms.Infrastructure.Scoping.Scope.Dispose()
   at Umbraco.Cms.Core.Services.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId)
   at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PublishInternal(ContentItemSave contentItem, String defaultCulture, String cultureForInvariantErrors, Boolean& wasCancelled, String[]& successfulCultures)
   at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSaveInternal[TVariant](ContentItemSave contentItem, Func`3 saveMethod, Func`2 mapToDisplay)
   at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSave(ContentItemSave contentItem)
   at lambda_method1955(Closure, Object)
   at 

If I remove the Tax type and attempt to re-publish it works, but then attempt to re-add the Tax it will fail again.

Further information:

When I edit the product, the Tax Type is displayed correctly, so it's obviously reading the data properly. It's only on save that it causes a problem.

robertjf commented 11 months ago

More detail on where this is actually thrown:

Cannot cast dataType configuration, of type StoreEntityPickerConfiguration, to Dictionary`2.

   at Umbraco.Extensions.DataTypeExtensions.ConfigurationAs[T](IDataType dataType) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Models\DataTypeExtensions.cs:line 75
   at Umbraco.Commerce.Deploy.Connectors.ValueConnectors.UmbracoCommerceStoreEntityPickerValueConnector.GetPropertyEntityType(IPropertyType propertyType)
   at Umbraco.Commerce.Deploy.Connectors.ValueConnectors.UmbracoCommerceStoreEntityPickerValueConnector.ToArtifact(Object value, IPropertyType propertyType, ICollection`1 dependencies)
   at Umbraco.Cms.Core.Deploy.ValueConnectorExtensions.ToArtifact(IValueConnector connector, Object value, IPropertyType propertyType, ICollection`1 dependencies, IContextCache contextCache) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Deploy\ValueConnectorExtensions.cs:line 28
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentConnector.ContentConnectorBase`2.SerializeNonVariantValue(ICollection`1 dependencies, Boolean published, IDictionary`2 propertyCollection, IProperty property, IValueConnector valueConnector, IContextCache contextCache)
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentConnector.ContentConnectorBase`2.AddProperty(IProperty property, ICollection`1 dependencies, Boolean published, IDictionary`2 propertyCollection, IContextCache contextCache)
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentConnector.ContentConnectorBase`2.MapArtifactProperties(IPropertyCollection properties, ICollection`1 dependencies, Boolean published, IContextCache contextCache)
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentConnector.DocumentConnectorBase.MapVersion(IContent content, ICollection`1 dependencies, Boolean published, IContextCache contextCache)
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentConnector.DocumentConnector.GetArtifact(GuidUdi udi, IContent content, IContextCache contextCache)
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentConnector.DocumentConnectorBase.GetArtifact(Object o, IContextCache contextCache)
   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ServiceConnectorBase`3.Umbraco.Cms.Core.Deploy.IServiceConnector2.GetArtifact(Object o, IContextCache contextCache)
   at Umbraco.Cms.Core.Deploy.ServiceConnectorExtensions.GetArtifact(IServiceConnector connector, Object entity, IContextCache contextCache) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Deploy\ServiceConnectorExtensions.cs:line 41
   at ServiceConnectorFactoryExtensions.<GetArtifacts>d__1`1.MoveNext()
   at ServiceConnectorFactoryExtensions.<GetArtifacts>d__0`1.MoveNext()
   at Umbraco.Deploy.Infrastructure.Persistence.SignatureRepository.SetSignatures(IEnumerable`1 signatures)
   at Umbraco.Deploy.Infrastructure.SignatureService.SetSignatures(IEnumerable`1 signatures)
   at Umbraco.Deploy.Infrastructure.SignatureService.SetSignatures[T](IEnumerable`1 entities)
   at Umbraco.Deploy.Core.NotificationHandlers.EntitySignatureDeployRefresherNotificationHandlerBase`3.Handle(IEnumerable`1 entities)
   at Umbraco.Deploy.Core.NotificationHandlers.DeployRefresherNotificationHandlerBase`2.Handle(IEnumerable`1 notifications)
   at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl`1.<>c__DisplayClass0_0`2.<Handle>b__2(IEnumerable`1 handlerNotifications) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\EventAggregator.Notifications.cs:line 284
   at Umbraco.Cms.Core.Events.EventAggregator.PublishCore[TNotification](IEnumerable`1 allHandlers, IEnumerable`1 notifications) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\EventAggregator.Notifications.cs:line 109
   at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl`1.Handle[TNotification,TNotificationHandler](IEnumerable`1 notifications, ServiceFactory serviceFactory, Action`2 publish) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\EventAggregator.Notifications.cs:line 286
   at Umbraco.Cms.Core.Events.EventAggregator.PublishNotifications[TNotification,TNotificationHandler](IEnumerable`1 notifications) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\EventAggregator.Notifications.cs:line 77
   at Umbraco.Cms.Core.Events.EventAggregator.Publish[TNotification,TNotificationHandler](IEnumerable`1 notifications) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\EventAggregator.cs:line 26
   at Umbraco.Cms.Core.Events.ScopedNotificationPublisher`1.PublishScopedNotifications(IList`1 notifications) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\ScopedNotificationPublisher.cs:line 117
   at Umbraco.Cms.Core.Events.ScopedNotificationPublisher`1.ScopeExit(Boolean completed) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Events\ScopedNotificationPublisher.cs:line 94
   at Umbraco.Cms.Core.Scoping.CoreScope.HandleScopedNotifications() in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Core\Scoping\CoreScope.cs:line 253
   at Umbraco.Cms.Infrastructure.Scoping.Scope.TryFinally(Action[] actions) in E:\Source\Repos\robertjf\Umbraco-CMS\src\Umbraco.Infrastructure\Scoping\Scope.cs:line 581
robertjf commented 11 months ago

I thought this might be a problem with upgrading from Umbraco.Commerce 10, but when I deleted the property and data type and recreated it, I get the same error.

mattbrailsford commented 11 months ago

I'm not quite sure how this worked in Umbraco Commerce 10. If we were speaking Vendr I'd understand, but I think this should have been broken in v10 as well. What specific v10 version were you on previously?

robertjf commented 11 months ago

@mattbrailsford here's the original PackageReferences:

    <PackageReference Include="Umbraco.Cms" Version="10.6.1" />
    <PackageReference Include="Umbraco.Commerce" Version="10.0.2" />
    <PackageReference Include="Umbraco.Commerce.Deploy" Version="10.0.0" />
    <PackageReference Include="Umbraco.Commerce.Checkout" Version="10.0.1" />
mattbrailsford commented 11 months ago

And you had a tax based store entity picker defined before that used to transfer fine?

robertjf commented 11 months ago

Yes... until I upgraded to v12 everything was working fine

mattbrailsford commented 11 months ago

Ok, then I'm really quite confused. v10 also used the StoreEntityPickerConfiguration strongly typed config, so it should have also errored.

I'll have to try and investigate further, but I have applied your fix and pushed to a 12.0.1 preview build on the nightly feed if you wanted to try it https://www.myget.org/F/umbraconightly/api/v3/index.json

mattbrailsford commented 11 months ago

Considering this resolved as the fix should work for both v10 and v12