Skip to content

Conversation

@lauraneto
Copy link
Contributor

Fixes #20409

This pull request improves the robustness of block item data deserialization in JsonBlockValueConverter by introducing a fallback mechanism for handling legacy data schemas and resolving conflicts with the values property, which was added in #17120.
The changes ensure that data from older formats can still be deserialized without errors, while making it clear that these methods are temporary and will be removed in a future version.

Deserialization robustness and legacy schema support:

  • Enhanced the DeserializeBlockItemData method to catch JsonExceptions related to the .values property and use a fallback deserialization approach for legacy data schemas.
  • Added a suite of [Obsolete] methods (FallbackBlockItemDataDeserialization, DeserializeBlockItemElement, DeserializeWithRenamedValues, CreateModifiedJsonWithRenamedValues, and RestoreOriginalValuesPropertyName) to handle legacy block item data, specifically addressing cases where the values property causes deserialization conflicts. These methods rename the conflicting property temporarily and restore it after deserialization.

Testing

The reporter of the issue added a repository that contains a SQLite database that will trigger the issue, but this can also be reproduced by simply creating a v13 solution with a block list configured with a block with a property called values, adding sample content and then trying to upgrade to v15+.
This fallback logic should only really be called during the V_15_0_0.ConvertBlockListEditorProperties migration. After that, the data should be fixed and the code shouldn't trigger anymore.

Copilot AI review requested due to automatic review settings October 8, 2025 14:39
Copy link
Contributor

Copilot AI left a 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 fixes a deserialization conflict in JsonBlockValueConverter where the values property conflicts with the internal Values collection used by the block system. The issue occurs when migrating from v13 to v15+ where legacy block data contains a user-defined property named "values".

  • Adds a try-catch mechanism to detect JsonExceptions related to .values property conflicts
  • Implements a fallback deserialization approach that temporarily renames conflicting properties
  • Introduces robust error handling for legacy data schemas during migration

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely @lauraneto - it's an edge case, but perhaps not an uncommon one, but good that we have it covered. I saw you pushed an update recently so I'll approve but not merge and leave you to do that when you are happy.

I pushed up a small unit test to verify the behaviour - this failed with the old code but passes with what you have in the PR. I also tested with the provided database.

@lauraneto lauraneto merged commit 1fe7931 into main Oct 9, 2025
25 checks passed
@lauraneto lauraneto deleted the v16/bugfix/conflicting-values-property-in-block-editors branch October 9, 2025 07:41
lauraneto added a commit that referenced this pull request Oct 9, 2025
…with 'values' property (#20429)

* Adjust the `JsonBlockValueConverter` to handle conflicts with 'values' property (due to old data schema)

* Simplify code

* Add unit test to verify change.

---------

Co-authored-by: Andy Butland <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlockList items are lost on upgrade v13 to v16

3 participants