Skip to content

fix: surface non-empty vault import destination#429

Open
Guardiola31337 wants to merge 1 commit into
mainfrom
bugfix/typed-vault-import-destination-error
Open

fix: surface non-empty vault import destination#429
Guardiola31337 wants to merge 1 commit into
mainfrom
bugfix/typed-vault-import-destination-error

Conversation

@Guardiola31337

@Guardiola31337 Guardiola31337 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

  • WalletKit backup import currently reports a non-empty destination as a generic vault database error from the lower-level SQLite copy guard.
  • For incident recovery flows, host apps need to distinguish this expected restore-state condition from fatal backup corruption or database failures without parsing the error message string.

Changes

  • Add StorageError::VaultImportDestinationNotEmpty { table } for vault backup imports into a destination that already has rows.
  • Preflight backup import destination tables before calling the lower-level plaintext copy guard.
  • Update the backup import test to assert the typed error while preserving the existing data-integrity check.

Testing Instructions

  • cargo fmt --all --check
  • cargo test -p walletkit-core import_vault_backup

Note

Low Risk
Small, localized change to backup import error handling and an early guard; no changes to encryption, credential writes, or successful restore paths.

Overview
Vault backup import now returns StorageError::VaultImportDestinationNotEmpty { table } when the destination already has rows in backup tables (credential_records, blob_objects), instead of a generic vault DB error from the SQLite copy path.

CredentialVault::import_plaintext runs a preflight ensure_backup_destination_empty before cipher::import_plaintext_copy. Public import_vault_from_backup docs note this case. The non-empty-vault test asserts the typed error and still checks data is unchanged after a failed import.

Reviewed by Cursor Bugbot for commit b244bb6. Bugbot is set up for automated code reviews on this repo. Configure here.

@Guardiola31337

Copy link
Copy Markdown
Contributor Author

Related Android incident PR: worldcoin/wld-android#7895 handles INC-109 in the app while this WalletKit PR makes the non-empty credential-vault import destination explicit for consumers.

@kilianglas kilianglas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants