{"record":{"id":"94110151d1aea91d","repo":"affaan-m/ECC","slug":"invalid-name-value-expected-a-path","errorCode":null,"errorMessage":"Invalid ${name} value: expected a path","messagePattern":"Invalid (.+?) value: expected a path","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/control-pane/server.js","lineNumber":58,"sourceCode":"    '',\n    'Options:',\n    '  --state-db <path>  Read agent work items from an ECC state-store database',\n    '  --read-only        Disable action execution endpoints',\n    '  --no-open          Do not open a browser after the server starts',\n    '  --help             Show this help'\n  ].join('\\n');\n}\n\nfunction valueAfter(args, name) {\n  const index = args.indexOf(name);\n  return index >= 0 ? args[index + 1] : null;\n}\n\nfunction pathValueAfter(args, name) {\n  const value = valueAfter(args, name);\n  if (value === null) return null;\n  if (!value || value.startsWith('-')) {\n    throw new Error(`Invalid ${name} value: expected a path`);\n  }\n  return value;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const help = args.includes('--help') || args.includes('-h');\n  const host = valueAfter(args, '--host') || '127.0.0.1';\n  const portValue = valueAfter(args, '--port') || '8765';\n  const port = Number.parseInt(portValue, 10);\n  if (!Number.isFinite(port) || port < 0 || port > 65535) {\n    throw new Error(`Invalid --port value: ${portValue}`);\n  }\n\n  return {\n    help,\n    host,\n    port,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/control-pane/server.js#L40-L76","documentation":"Thrown by pathValueAfter at scripts/lib/control-pane/server.js:54-61 when a parsed argument value is empty or starts with '-' (i.e. looks like another flag, not a path). pathValueAfter is a stricter variant of valueAfter used specifically for path-typed options; it forbids flag-shaped values to catch missing-argument mistakes. In parseArgs it is currently applied only to --state-db (server.js:78), so the interpolated name will normally be '--state-db'. Other path-like options (--db, --config) use the more permissive valueAfter and do not trigger this error.","triggerScenarios":"`node scripts/control-pane.js --state-db` (no value follows); `--state-db --read-only` (next token is a flag); `--state-db ''` (empty value); `--state-db -h`. The check at server.js:57 fires when value is falsy or starts with '-'.","commonSituations":"Operator forgets to pass the path after --state-db; a script concatenates flags and drops the value during argv construction; copy/paste from docs that line-break between flag and value; an empty environment variable expansion produces an empty token.","solutions":["Provide a non-flag path: `--state-db /path/to/state.db`.","If the value legitimately starts with '-', use an absolute path (which starts with '/', not '-').","Quote shell expansions to avoid empty tokens: `--state-db \"$STATE_DB\"` and ensure STATE_DB is set.","If you want --state-db to be optional, simply omit it — pathValueAfter returns null when the flag is absent (server.js:56)."],"exampleFix":"// before\n$ node scripts/control-pane.js --state-db --read-only\n// after\n$ node scripts/control-pane.js --state-db /home/u/state.db --read-only","handlingStrategy":"validation","validationCode":"function parsePathOption(argv, name) {\n  const i = argv.indexOf(name);\n  if (i < 0) return null;\n  const v = argv[i + 1];\n  if (!v || v.startsWith('-')) throw new Error(`Invalid ${name} value: expected a path`);\n  return v;\n}\nparsePathOption(process.argv.slice(2), '--state-db');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote the path value in the shell and ensure it is non-empty.","In wrapper scripts, default unset path vars to a concrete absolute path rather than passing an empty string.","Document that --state-db is the strict path option; --db and --config are permissive."],"tags":["control-pane","validation","cli","path","arguments"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}