fix(startup): ignore blank data dir override

Treat empty or whitespace-only dataDirOverride values as unset so
bootstrapEnv keeps using the normal DATA_DIR and .env lookup path.

Adds a focused regression test for the whitespace override case.
This commit is contained in:
Kfir Amar
2026-03-14 21:29:34 +02:00
parent da39e1485f
commit e3a2bd75f3
2 changed files with 12 additions and 1 deletions

View File

@@ -35,7 +35,7 @@ const OPTIONAL_OAUTH_SECRETS = [
// ── Resolve DATA_DIR (mirrors dataPaths.ts logic) ───────────────────────────
function resolveDataDir(overridePath, env = process.env) {
if (overridePath) return resolve(overridePath);
if (overridePath?.trim()) return resolve(overridePath);
const configured = env.DATA_DIR?.trim();
if (configured) return resolve(configured);

View File

@@ -100,3 +100,14 @@ test("bootstrapEnv fails closed when existing database cannot be inspected", ()
);
});
});
test("bootstrapEnv ignores blank dataDirOverride values", () => {
withTempEnv(({ dataDir }) => {
fs.mkdirSync(dataDir, { recursive: true });
fs.writeFileSync(path.join(dataDir, ".env"), "JWT_SECRET=jwt-from-dot-env\n", "utf8");
const env = bootstrapEnv({ dataDirOverride: " ", quiet: true });
assert.equal(env.JWT_SECRET, "jwt-from-dot-env");
});
});