umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

Upgrade from 10.5.2 to 13.0.1 breaks Form Entries #1157

Closed AaronSadlerUK closed 5 months ago

AaronSadlerUK commented 5 months ago

It's possible to upgrade Umbraco Forms with existing entries from 8.13.13 to 10.5.2, however the Entries blade fails to load after upgrading from 10.5.2 to either 13.0.0 or 13.0.1

The below exception is thrown in the network tab:

    "ExceptionMessage": "Object reference not set to an instance of an object.",
    "ExceptionType": "System.NullReferenceException, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
    "StackTrace": "   at Umbraco.Forms.Core.Models.Form.ApplyDictionaryTranslationsToPrevalueCaptions(IDictionaryHelper dictionaryHelper)\r\n   at Umbraco.Forms.Web.Editors.FormController.GetWithWorkflowsByGuid(Guid guid, Boolean applyDictionaryTranslations)\r\n   at lambda_method834(Closure, Object, Object[])\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"
}

It is possible to view on the website frontend, complete and edit in the backend however not view any of the entries in the backoffice. All workflows run to completion with no errors.


This item has been added to our backlog AB#37553

AaronSadlerUK commented 5 months ago

Just an update to save that by Re-Saving the forms I can now view the entries...

So something between 10 and 13 doesn't seem to be running correctly, are there schema or table changes?

AndyButland commented 5 months ago

I've had a look into this and whilst I couldn't replicate from an upgrade, I could from the stack trace you shared see where the error was occurring. It seems there's a collection - for prevalues on a field - that we are expecting to be empty, but is in fact null. The data comes from what's stored in the database for the form definition, so although we are always saving empty collections, it looks like at least in some earlier versions it was possible to save a null value. And when we deserialize, even though the property is marked as not being nullable, it can be.

I can replicate it by manipulating the data in the database field - setting "preValues":null in UFForms.Definition - and see what you have seen.

The fact that you see the problem go away once the form is resaved corroborates this (as then an empty, non-null value, is saved).

A null check will be added to the next patch releases to ensure this doesn't occur moving forward.

AaronSadlerUK commented 5 months ago

Brilliant, thanks for looking into it!