fix(db): default debugMode to false in getSettings() defaults (#10372)

* fix(db): default debugMode to false in getSettings() defaults

Fresh installs (or installs missing the persisted debugMode key) ran in
debug mode, contradicting the documented opt-in toggle and flooding new
production installs with debug-level logs. Flip the default to false;
installs that persisted debugMode=true keep it — only the missing-key
path changes, no migration needed.

Fixes #10312

* changelog: fragment for #10372
This commit is contained in:
Jacky Lam
2026-08-16 11:15:51 +08:00
committed by GitHub
parent b19e9772bc
commit 149049ca4a
3 changed files with 54 additions and 1 deletions

View File

@@ -0,0 +1 @@
- **fix(db):** `getSettings()` defaults `debugMode` to `false` — fresh installs no longer run in debug mode (persisted `debugMode: true` is preserved) ([#10372](https://github.com/diegosouzapw/OmniRoute/pull/10372) — thanks @lamchun1110)

View File

@@ -212,7 +212,9 @@ export async function getSettings() {
idempotencyWindowMs: 5000,
wsAuth: false,
maxBodySizeMb: requestBodyLimitMbFromEnv(process.env.MAX_BODY_SIZE_BYTES),
debugMode: true,
// #10312: opt-in only — a fresh install (or one missing the persisted key)
// must not run in debug mode; installs that persisted `true` keep it.
debugMode: false,
// Opt-in diagnostic: when true, the chat handler emits a `log.debug("TOOLS", …)`
// line per request summarizing tool count + MCP/hosted/client source breakdown.
logToolSources: false,

View File

@@ -0,0 +1,50 @@
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-settings-debug-"));
process.env.DATA_DIR = TEST_DATA_DIR;
const core = await import("../../src/lib/db/core.ts");
const settings = await import("../../src/lib/db/settings.ts");
async function resetStorage() {
const globalDb = (globalThis as { __omnirouteDb?: { open: boolean; close(): void } })
.__omnirouteDb;
try {
if (globalDb?.open) {
globalDb.close();
}
} catch {}
delete (globalThis as { __omnirouteDb?: unknown }).__omnirouteDb;
core.resetDbInstance();
if (fs.existsSync(TEST_DATA_DIR)) {
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
}
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
core.getDbInstance();
}
await resetStorage();
test("#10312: empty store defaults debugMode to false (fresh install is not in debug)", async () => {
await resetStorage();
const result = await settings.getSettings();
assert.equal(result.debugMode, false);
});
test("#10312: persisted debugMode=true is preserved after the default flip", async () => {
await resetStorage();
await settings.updateSettings({ debugMode: true });
const result = await settings.getSettings();
assert.equal(result.debugMode, true);
});
test("#10312: persisted debugMode=false stays false after the default flip", async () => {
await resetStorage();
await settings.updateSettings({ debugMode: false });
const result = await settings.getSettings();
assert.equal(result.debugMode, false);
});