8000 Add data migration for widgets from string to JSON format by dkbennett · Pull Request #331 · microsoft/devhomegithubextension · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Add data migration for widgets from string to JSON format#331

Merged
EricJohnson327 merged 6 commits intomainfrom
user/dkbennett/widgetdatamigration
Jan 25, 2024
Merged

Add data migration for widgets from string to JSON format#331
EricJohnson327 merged 6 commits intomainfrom
user/dkbennett/widgetdatamigration

Conversation

@dkbennett
Copy link
Member

Summary of the pull request

The multi-account support changes also changed the widget state from a string to a JSON string so we could encode more flexible data. However, existing widget data is still the string format, so to prevent users from losing their widget configuration we needed to add migration code to convert the string format to the JSON string format. This PR adds that for the two categories of widgets, the Repository widget and the User widget.

References and relevant issues

https://task.ms/48658002

Detailed description of the pull request / Additional comments

This fix is not a robust migration support feature with data versioning and migrating from version N to version M, which we should absolutely add before making any further data format changes. This change is a rather crude existence check for the old format and changing it to the new format by seeing if it fails JSON parsing and if so, assume it is the old format and convert to the new format. This is a quick fix to unblock the release.

Changes:

  • Updated the exception handling when we fail to parse the JSON data to not reset the data to default values, but instead attempt migration if possible.
  • In the case of the Repository class of widgets, the old state was a URI string to a repository, so that simply added the repository into the JSON data format and used that instead.
  • In the case of the User class of widgets, the old state was a searchCategory string name, so that was converted to the data. In addition, with multi-account support, the User class of widgets also needed a selected devId, which was not data we previously had in these widgets. This fix assumes that in the event there was exactly one developer id, use that developer id. If there was not one exactly then we would leave that set to the default, which puts the Widget back in the configuration state allowing the user to select which account they wanted to use.

Strongly recommend a future task to add data versioning to the widget data as one of the JSON node values and adding a widget check on creation that compares the current data version to the one the widget expects and to handle any migration if necessary.

Validation steps performed

  • Verified migration scenario by injecting the old string value into the ConfigurationData, which forced the migration code to execute. Confirmed that the code handles that data as-expected for both types of widgets.
  • Verified widgets normally work as expected.

PR checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated

@EricJohnson327 EricJohnson327 merged commit fa3d502 into main Jan 25, 2024
@EricJohnson327 EricJohnson327 deleted the user/dkbennett/widgetdatamigration branch January 25, 2024 00:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0