t8y2/dbx · error · Error
Invalid ${name}: ${error.message}
Error message
Invalid ${name}: ${error.message} What it means
parseJsonEnv reads an environment variable expected to contain JSON and throws Error('Invalid <name>: <error.message>') when JSON.parse fails. The bridge uses it for MCP_ARGS_ENV and ENABLED_TOOLS_ENV, so malformed JSON in those variables aborts startup.
Source
Thrown at crates/dbx-core/assets/pi-mcp-bridge.mjs:17
import { spawn } from "node:child_process";
import { writeFile } from "node:fs/promises";
import { createInterface } from "node:readline";
const MCP_PROGRAM_ENV = "DBX_PI_MCP_PROGRAM";
const MCP_ARGS_ENV = "DBX_PI_MCP_ARGS";
const ENABLED_TOOLS_ENV = "DBX_PI_ENABLED_TOOLS";
const READY_FILE_ENV = "DBX_PI_BRIDGE_READY_FILE";
const REQUEST_TIMEOUT_MS = 30_000;
function parseJsonEnv(name, fallback) {
const value = process.env[name];
if (!value) return fallback;
try {
return JSON.parse(value);
} catch (error) {
throw new Error(`Invalid ${name}: ${error.message}`);
}
}
function textFromContent(content) {
return (content ?? [])
.filter((item) => item?.type === "text" && typeof item.text === "string")
.map((item) => item.text)
.join("\n");
}
function piContent(content) {
const result = [];
for (const item of content ?? []) {
if (item?.type === "text" && typeof item.text === "string") {
result.push({ type: "text", text: item.text });
} else if (
item?.type === "image" &&
typeof item.data === "string" &&View on GitHub (pinned to c0390bff16)
Solutions
- Set the env var to valid JSON, e.g. DBX_PI_MCP_ARGS='["-m","server"]' with double quotes inside
- Validate with `echo "$VAR" | python3 -m json.tool` or JSON.parse in node before launch
- Prefer a config file/generated env over hand-written shell escaping; check how your shell/systemd/compose passes quotes
Example fix
// before export DBX_PI_MCP_ARGS=["-m","pi_server"] # shell strips quotes -> invalid JSON // after export DBX_PI_MCP_ARGS='["-m","pi_server"]'
Defensive patterns
Strategy: validation
Validate before calling
function assertJsonEnv(name) {
const v = process.env[name];
if (v) JSON.parse(v); // throws early with clear context
}
assertJsonEnv('DBX_PI_MCP_ARGS');
assertJsonEnv('DBX_PI_MCP_ENABLED_TOOLS'); Type guard
function isJsonObjectString(v) {
try { const p = JSON.parse(v); return p !== null && typeof p === 'object'; }
catch { return false; }
} Try / catch
try {
const args = parseJsonEnv('DBX_PI_MCP_ARGS', []);
} catch (e) {
console.error('Env DBX_PI_MCP_ARGS is not valid JSON:', e.message);
process.exit(1);
} Prevention
- Single-quote JSON values in shell so double quotes survive
- Validate env JSON before launching the bridge
- Avoid hand-editing: generate env from a config file
When it happens
Trigger: DBX_PI_MCP_ARGS or DBX_PI_MCP_ENABLED_TOOLS (the configured env names) contain non-JSON text, single quotes instead of double quotes, trailing commas, or are truncated by a size limit.
Common situations: Hand-editing env vars in shell (shell quoting strips double quotes); container orchestration templates interpolating incorrectly; log-serialization truncating long values.
Related errors
- DBX Pi MCP bridge configuration is incomplete
- JSON registration has no endpoint
- DBX_PUBLIC_BASE_PATH contains invalid characters
- Agent runtime thread limits must be positive
- H2 JDBC driver rejected URL: " + buildJdbcUrl(params)
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/71bf1fe5aca58de3.
Report an issue: GitHub.