{"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":60,"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":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/control-pane/server.js#L42-L78","documentation":"pathValueAfter extracts the value following a CLI flag (e.g. --repo-root) in the control-pane server's argument parser and rejects values that are missing, empty, or start with '-' (i.e. another flag was consumed as the value). It ensures path-typed options receive an actual path string.","triggerScenarios":"Running the server as `node server.js --repo-root` (no value), `--repo-root --port 8765` (next flag eaten as value), or `--repo-root \"\"`.","commonSituations":"Shell variable for the path is empty/unset ($REPO_ROOT expands to nothing); flag order mistakes; quoting errors that drop the argument.","solutions":["Provide the path immediately after the flag: --repo-root /path/to/repo","Check that any shell variable holding the path is non-empty and quoted","Reorder arguments so the path value precedes other flags","Run with --help to confirm the flag names and expected values"],"exampleFix":"// before\n$ node server.js --repo-root $ROOT --port 8765   # ROOT empty\n// after\n$ node server.js --repo-root \"$PWD\" --port 8765","handlingStrategy":"validation","validationCode":"const idx = args.indexOf('--repo-root');\nconst val = idx !== -1 ? args[idx + 1] : null;\nif (val !== null && (!val || val.startsWith('-'))) throw new Error('missing value for --repo-root');","typeGuard":"const isPathValue = (v) => typeof v === 'string' && v.length > 0 && !v.startsWith('-');","tryCatchPattern":"try { const opts = parseArgs(process.argv); } catch (e) {\n  if (String(e.message).includes('expected a path')) console.error('Provide a non-empty path after path flags');\n  else throw e;\n}","preventionTips":["Quote shell variables holding paths: --repo-root \"$ROOT\"","Verify path variables are non-empty before invoking","Put path values immediately after their flags","Run --help to confirm accepted flags"],"tags":["cli","arguments","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}