fix(startup): fail closed on key inspection errors

Propagate database inspection failures instead of treating them as
missing encrypted credentials.

This keeps startup from generating a fresh encryption key when an
existing database cannot be inspected and adds a regression test for
that path.
This commit is contained in:
Kfir Amar
2026-03-14 21:23:07 +02:00
parent 88cc53a4b0
commit da39e1485f
3 changed files with 17 additions and 4 deletions

View File

@@ -87,8 +87,9 @@ function hasEncryptedCredentials(dataDir) {
} finally {
db.close();
}
} catch {
return false;
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Error(`Unable to inspect existing database at ${dbPath}: ${message}`);
}
}