MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.1k stars 1.09k forks source link

Error: The specified item already exists in the keychain. #9419

Open sentry-io[bot] opened 4 months ago

sentry-io[bot] commented 4 months ago

Sentry Issue: METAMASK-MOBILE-2BAS

Error: The specified item already exists in the keychain.
  at r (ses.cjs:7575:17)
  at backupVault (app/core/BackupVault/backupVault.ts:41:32)
  at backupVault (app/core/BackupVault/backupVault.ts:67:2)
  at <global> (app/core/BackupVault/backupVault.ts:37:34)
  at controllerMessenger.subscribe$argument_1 (app/core/Engine.ts:895:9)
...
(45 additional frame(s) were not displayed)
gauthierpetetin commented 4 months ago

Hi @gantunesr @mikesposito @Gudahtt do we have an idea when this situation can happen? => We try to save an item in the vault but the item is already included in the vault.

mikesposito commented 4 months ago

The error should be thrown by

const backupResult = await setInternetCredentials(
    VAULT_BACKUP_KEY,
    VAULT_BACKUP_KEY,
    keyringState.vault,
    options,
);

setInternetCredentials comes from the react-native-keychain package, and apparently, the package throws that error when the credentials we are trying to save already exist in the OS keychain

So with "keychain" the error is not referring to our vault in this case, but the vault backup fails for some reason

mikesposito commented 4 months ago

But this does not make much sense, since the credentials at slot VAULT_BACKUP_KEY should be expected to exist, since we update the value stored each time the user vault is updated. So I'm still unsure about which case would make react-native-keychain complain, instead of just overwriting the credentials

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.