fix: migrate legacy backups missing wallet id on restore#619
fix: migrate legacy backups missing wallet id on restore#619coreyphillips wants to merge 1 commit into
Conversation
Backups written before activity data became wallet-scoped have no wallet id on their activity, tag and pre-activity-metadata records. With bitkit-core 0.4.0 those records require a wallet id, so decoding such a backup throws before the records reach Core. Before decoding a restored envelope, hand each Core-owned array to the matching bitkit-core migration helper (migrateBackupActivitiesJson, migrateBackupActivityTagsJson, migrateBackupPreActivityMetadataJson), which fills in the default wallet id for records that lack one and preserves any existing id. The app never edits Core model JSON itself, and current backups that already carry a wallet id are unaffected. Bumps bitkit-core to 0.4.0.
Greptile SummaryThis PR adds a restore-time migration for legacy Core backup data. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| Bitkit/Services/BackupService.swift | Adds restore-time migration for Core-owned activity and metadata backup arrays before decoding. |
| Bitkit.xcodeproj/project.pbxproj | Updates the bitkit-core package requirement to 0.4.0. |
| Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved | Updates the resolved bitkit-core revision and version. |
Reviews (1): Last reviewed commit: "fix: migrate legacy backups missing wall..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8cd698d5c0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let migrated = try self.migrateCoreOwnedBackupFields(dataBytes, fieldMigrations: [ | ||
| "activities": migrateBackupActivitiesJson, | ||
| "activityTags": migrateBackupActivityTagsJson, | ||
| ]) |
There was a problem hiding this comment.
Add the required changelog fragment
This commit is a user-facing fix: because it restores legacy backups that otherwise fail to decode, but it does not add a fragment under changelog.d/next/; root AGENTS.md says “ALWAYS add exactly ONE changelog fragment for user-facing feat: and fix: PRs”. Without the fragment, release automation will omit this restore fix from the release notes.
Useful? React with 👍 / 👎.
Summary
Stacked on #617. Legacy backups that predate wallet-scoped activity data fail to decode on restore because their activity, tag and pre-activity-metadata records have no wallet id, and with bitkit-core 0.4.0 those records require one. The decode throws before the records reach Core.
Approach
Before decoding a restored envelope, each Core-owned array (
activities,activityTags,tagMetadata) is handed to the matching bitkit-core migration helper as raw JSON:migrateBackupActivitiesJsonmigrateBackupActivityTagsJsonmigrateBackupPreActivityMetadataJsonCore fills in the default wallet id for records that lack one (or have it empty) and preserves any existing non-default id such as
trezor:{hash}. The app only extracts and reinserts the sub-arrays viaJSONSerialization, so it never edits Core model JSON itself. The helpers are idempotent, so current backups that already carry a wallet id are unaffected.This is the iOS half of synonymdev/bitkit-core#113; the migration APIs it calls shipped in bitkit-core 0.4.0.
Changes
BackupService.swift: addmigrateCoreOwnedBackupFieldsand apply it at the.activityand.metadatarestore sites.Notes
chore/bump-bitkit-core-0.3.9(refactor: typed Trezor device-busy handling #617), which introduces the wallet-scoped restore path this builds on. Retarget tomasteronce refactor: typed Trezor device-busy handling #617 merges.