core: add logs to diagnose why decryption fails after changing password (#10139)

This commit is contained in:
Abdullah Atta
2026-07-27 10:20:25 +05:00
committed by GitHub
parent 771a8bb4e3
commit 32070327f9
2 changed files with 13 additions and 0 deletions

View File

@@ -387,6 +387,10 @@ export class Sync {
const itemsToDecrypt = itemsByKeyVersion.get(keyInfo.version);
if (!itemsToDecrypt || itemsToDecrypt.length === 0) continue;
this.logger.info("Decrypting using key", {
keyInfo: keyInfo.version,
items: itemsToDecrypt.length
});
decrypted.push(
...(await this.db.storage().decryptMulti(keyInfo.key, itemsToDecrypt))
);

View File

@@ -404,11 +404,13 @@ class UserManager {
{ version: KeyVersion; key: SerializedKey }[] | undefined
> {
const masterKey = await this.getMasterKey();
logger.info("master key exists: ", { masterKey: !!masterKey });
if (!masterKey) return;
const dataEncryptionKey = await this.keyManager.get("dataEncryptionKey", {
refetchUser: false
});
logger.info("DEK exists: ", { dataEncryptionKey: !!dataEncryptionKey });
if (!dataEncryptionKey)
return [
{
@@ -424,6 +426,9 @@ class UserManager {
refetchUser: false
}
);
logger.info("legacy DEK exists: ", {
legacyDataEncryptionKey: !!legacyDataEncryptionKey
});
if (legacyDataEncryptionKey)
keys.push({
key: await this.keyManager.unwrapKey(
@@ -436,6 +441,10 @@ class UserManager {
key: await this.keyManager.unwrapKey(dataEncryptionKey, masterKey),
version: KEY_VERSION.DEK
});
logger.info("Keys:", {
keys: keys.length,
keyVersions: keys.map((k) => k.version)
});
return keys;
}