-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Avoid throwing an exception on getting references when migrating content with changed data types #20079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid throwing an exception on getting references when migrating content with changed data types #20079
Conversation
…ent with changed data types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds error handling to block editor value deserialization to avoid throwing exceptions when retrieving references during content migration. The change allows the system to gracefully handle malformed data when migrating from nested content to block list formats.
Key changes:
- Added optional
throwOnError
parameter to block editor deserialization methods - Wrapped deserialization in try-catch to log warnings instead of throwing exceptions when
throwOnError
is false - Modified reference retrieval to use non-throwing mode to allow partial parsing of valid data
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/Umbraco.Infrastructure/PropertyEditors/BlockEditorValues.cs | Added error handling with optional logging to deserialization method |
src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs | Modified reference retrieval to use non-throwing mode for graceful migration handling |
src/Umbraco.Infrastructure/PropertyEditors/BlockEditorValues.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and would indeed make sure the property data can be updated/migrated (see umbraco/Umbraco.Deploy.Issues#270).
However, updating the relations is still done in ContentRepositoryBase.PersistRelations()
that is called on each and every save operation (for documents, media and members): this should be moved into a notification handler (inheriting from IDistributedNotificationHandler
to ensure it's also handled after Deploy operations).
Besides the performance overhead of parsing all property values, fetching related entities and updating the relations when an item is saved multiple times in a single scope/transaction, the timing is also not optimal. If a content item is transferred to another environment using Deploy, any missing media will be transferred as well, but if the content is saved before the media was created, the relations won't be created. This can be fixed by re-saving the content again after the deployment is completed, but that just exaggerates the performance issue. Because notifications (published on the scope) are handled after the scope/transaction is completed, this also ensures all related items exists. I'll create a separate issue for this, so this fix can be released as soon as possible (as it blocks customers from migrating to later majors).
@AndyButland @ronaldbarendse I have moved the exception handling to the consumer side, so the changes remain isolated inside |
Looks fine to me - and better if we align other "try/catch" checks already there for the editor value transformations. |
Prerequisites
Resolves: #19784
Description
This PR adds an option to log rather than throw when encountering an exception deserializating block values, that can be used to avoid an exception when retrieving references.
We have had cases where content is being migrated to a new data type via uSync or Deploy, where the parsed content is in a format for nested content rather than block list, and this then blows up, preventing the migration. It happens when retrieving references, which isn't essential to the operation, so it's reasonable to to just skip values that can't be parsed into an excepted format, and from where references can be obtained.
Testing
Testing is tricky, so it maybe that visual inspection is enough here. But I've been able to trigger the problem from a clean install with this setup, and verified that after this update the migration succeeds:
Umbraco.Deploy.OnPrem
.