{"record":{"id":"754f644d15e370dd","repo":"affaan-m/ECC","slug":"unknown-argument-arg-754f64","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/status.js","lineNumber":54,"sourceCode":"    if (arg === '--db') {\n      parsed.dbPath = args[index + 1] || null;\n      index += 1;\n    } else if (arg === '--json') {\n      parsed.json = true;\n    } else if (arg === '--markdown') {\n      parsed.markdown = true;\n    } else if (arg === '--exit-code') {\n      parsed.exitCode = true;\n    } else if (arg === '--write') {\n      parsed.writePath = args[index + 1] || null;\n      index += 1;\n    } else if (arg === '--limit') {\n      parsed.limit = args[index + 1] || null;\n      index += 1;\n    } else if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  if (parsed.json && parsed.markdown) {\n    throw new Error('Choose only one output format: --json or --markdown');\n  }\n\n  if (args.includes('--db') && !parsed.dbPath) {\n    throw new Error('Missing value for --db');\n  }\n\n  if (args.includes('--write') && !parsed.writePath) {\n    throw new Error('Missing value for --write');\n  }\n\n  if (args.includes('--limit') && !parsed.limit) {\n    throw new Error('Missing value for --limit');\n  }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/status.js#L36-L72","documentation":"Thrown by scripts/status.js parseArgs when an argv token is not one of the recognized flags: --db, --json, --markdown, --exit-code, --write, --limit, --help, or -h. The parser is a strict allowlist with no pass-through for unknown options, so any unlisted flag aborts before the SQLite state store is opened. This is a fail-fast guard so malformed invocations surface immediately instead of silently producing partial status output.","triggerScenarios":"Passing any flag outside the recognized set, e.g. `node scripts/status.js --verbose`, `--output report.txt`, `-v`, or `--format json` (the correct flag is --json). Also triggered by a flag that was renamed or removed in a newer ECC version while a wrapper script still passes the old spelling.","commonSituations":"Wrapper scripts or CI jobs hard-coding flags from an older ECC release; typos like `--josn` or `--wrtie`; copy-pasting a flag from a different CLI (e.g. --format from another tool) into an ECC status command; shell aliases that append extra flags.","solutions":["Run `node scripts/status.js --help` to list the valid flags and compare against the failing invocation.","Check the exact spelling of the flag reported in the error message and correct the typo.","If a wrapper script passes the flag, update it to the current flag name or remove the unsupported option.","Confirm you are on the ECC version whose flag set you expect (the parser only accepts the eight flags listed in showHelp)."],"exampleFix":"// before\nnode scripts/status.js --output report.txt\n\n// after\nnode scripts/status.js --json --write report.txt","handlingStrategy":"validation","validationCode":"// Validate status.js args before spawning the script\nconst STATUS_FLAGS = new Set(['--db', '--json', '--markdown', '--exit-code', '--write', '--limit', '--help', '-h']);\nconst VALUE_FLAGS = new Set(['--db', '--write', '--limit']);\n\nfunction validateStatusArgs(argv) {\n  for (let i = 0; i < argv.length; i++) {\n    const tok = argv[i];\n    if (tok.startsWith('-') && !STATUS_FLAGS.has(tok)) {\n      throw new Error(`Unsupported status.js flag: ${tok}`);\n    }\n    if (VALUE_FLAGS.has(tok) && (i + 1 >= argv.length || !argv[i + 1])) {\n      throw new Error(`Flag ${tok} needs a value`);\n    }\n    if (VALUE_FLAGS.has(tok)) i += 1; // skip the value\n  }\n}\n// validateStatusArgs(['--json', '--write', '/tmp/out.json']); // ok\n// validateStatusArgs(['--verbose']); // throws early","typeGuard":null,"tryCatchPattern":"// When invoking status.js programmatically, capture stderr + exit code\nconst { spawnSync } = require('child_process');\nconst r = spawnSync(process.execPath, ['scripts/status.js', ...userArgs], { encoding: 'utf8' });\nif (r.status !== 0) {\n  const msg = (r.stderr || '').trim();\n  if (msg.startsWith('Error: Unknown argument')) {\n    // surface a friendly hint to the caller and fall back to --help\n    console.error('status.js rejected a flag. Run with --help for the valid set.');\n  }\n  throw new Error(`status.js failed (${r.status}): ${msg}`);\n}","preventionTips":["Centralize ECC CLI flag construction in one helper so typos are caught in one place.","Pin the ECC version in CI so the flag set matches what your wrapper was written against.","Add a smoke test that runs `node scripts/status.js --help` and asserts exit 0 before real invocations."],"tags":["cli","argument-parsing","status","validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}