umbraco / Umbraco.Commerce.Issues

17 stars 2 forks source link

Order List is throwing error #414

Open philipdanielhayton opened 1 year ago

philipdanielhayton commented 1 year ago

Hi Matt,

There is an issue I've ran into on two separate projects that causes the Order Listing screen to fail whenever I try to access it. Unfortunately I'm not entirely sure what causes it, I realize this is not ideal for you to debug with so if there is anything further I can provide please let me now. Here's what I know for sure:

I'm guessing one of the orders has somehow ended up in an invalid state. I've had a quick scan through the orders table and nothing is jumping out at me. Is there anything in the soure code that could provide some clues for me to continue digging?

Value cannot be null. (Parameter 'type')

at Vendr.Infrastructure.Resiliency.PollyExecutionStrategyBase.Execute[TResult](Func`1 operation, Func`1 verifySucceeded)
   at Vendr.Core.VendrUnitOfWorkProvider.Execute[T](Boolean autoComplete, Func`2 action)
   at Vendr.Core.Services.OrderService.SearchOrders(IQuerySpecification`1 query, ISortSpecification`1 sort, Int64 currentPage, Int64 itemsPerPage)
   at Vendr.Core.Services.OrderService.SearchOrders(Func`2 query, Int64 currentPage, Int64 itemsPerPage)
   at Vendr.Umbraco.Web.Controllers.VendrOrderController.SearchOrders(OrderSearchDto model)
   at lambda_method2102(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
mattbrailsford commented 1 year ago

Did you every have a price / amount adjustment setup that you've since deleted? If this is the case, once you've created and used a price adjustment you shouldn't be deleting it as passed orders will attempt to deserialize their stored value into the right adjustment type and if that type has now gone, it will fail and error.

philipdanielhayton commented 1 year ago

Ah ok things are starting to make sense. I haven't removed any but I have refactored the codebase which resulted in namespace changes.

I'll try updating the type field in the database to the new namespace.

philipdanielhayton commented 1 year ago

Yup, that's fixed it 👍🏻 Thanks for the quick reply Matt, as always.

Is it possible to make this more resilliant to codebase changes? It seems a bit tedious (and dangerous) having to manually update the database whenever the codebase changes. In my case I had only moved the class to a different folder to keep things clean as we added more adjustment types. Perhaps we could use alias via attribute decorators or something?

Anyway, thanks again for the swift reply, got me out of a right pickle!

mattbrailsford commented 1 year ago

Good thinking, I'll see what could be done here, and maybe at least throw a better exception.