diff --git a/scripts/bootstrap-env.mjs b/scripts/bootstrap-env.mjs index 2e0a0a059e..a3c1c6fbaa 100644 --- a/scripts/bootstrap-env.mjs +++ b/scripts/bootstrap-env.mjs @@ -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); diff --git a/tests/unit/bootstrap-env.test.mjs b/tests/unit/bootstrap-env.test.mjs index e8d271fb53..6249c44ade 100644 --- a/tests/unit/bootstrap-env.test.mjs +++ b/tests/unit/bootstrap-env.test.mjs @@ -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"); + }); +});