{"record":{"id":"6b4946d14c78cee7","repo":"affaan-m/ECC","slug":"unknown-argument-arg-6b4946","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/operator-readiness-dashboard.js","lineNumber":214,"sourceCode":"    }\n\n    if (arg === '--generated-at') {\n      parsed.generatedAt = readValue(args, index, arg);\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--generated-at=')) {\n      parsed.generatedAt = arg.slice('--generated-at='.length);\n      continue;\n    }\n\n    if (arg === '--exit-code') {\n      parsed.exitCode = true;\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json', 'markdown'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);\n  }\n\n  if (parsed.writePath && parsed.format === 'text') {\n    throw new Error('--write requires --json, --markdown, or --format json|markdown');\n  }\n\n  parsed.allowUntracked = parsed.allowUntracked.map(normalizeRelativePrefix).filter(Boolean);\n\n  return parsed;\n}\n\nfunction readText(rootDir, relativePath) {\n  try {\n    return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/operator-readiness-dashboard.js#L196-L232","documentation":"The CLI argument parser in scripts/operator-readiness-dashboard.js rejects any command-line flag it does not recognize. parseArgs whitelists known flags (--format, --json, --markdown, --write, --exit-code, --allow-untracked, etc.) and throws this error for anything else, so typos or flags borrowed from other tools fail fast at startup.","triggerScenarios":"Running the dashboard script with a misspelled or unsupported flag, e.g. `node scripts/operator-readiness-dashboard.js --formt json`, an unimplemented flag like `--verbose`, or a positional argument the parser does not skip, all reach the `throw new Error(\\`Unknown argument: ${arg}\\`)` line.","commonSituations":"Typo in a flag from memory or documentation; copying flags from another ECC script (e.g. passing `--out` instead of `--write`); shell scripts built before a flag was renamed; quoting mistakes that turn a value into a standalone token (e.g. `--format json extra`).","solutions":["Read the error message: it names the exact unrecognized argument; fix the typo or remove the flag.","Run `node scripts/operator-readiness-dashboard.js --help` (or read the top of parseArgs) to list supported flags.","Use the documented shorthand flags instead: `--json`, `--markdown`, `--format <fmt>`, `--write <path>`, `--exit-code`.","If the flag is genuinely needed, add an explicit parsing branch for it in parseArgs before the throw."],"exampleFix":"// before\nnode scripts/operator-readiness-dashboard.js --format=jason\n// after\nnode scripts/operator-readiness-dashboard.js --format=json","handlingStrategy":"validation","validationCode":"const ALLOWED = ['--format','--json','--markdown','--write','--exit-code','--allow-untracked'];\nconst unknown = args.filter(a => a.startsWith('--') && !ALLOWED.some(k => a === k || a.startsWith(k + '=')));\nif (unknown.length) { console.error('Unknown flags:', unknown.join(', ')); process.exit(2); }","typeGuard":"function isKnownFlag(arg, allowed) { return typeof arg === 'string' && allowed.includes(arg); }","tryCatchPattern":"try {\n  const parsed = parseArgs(process.argv.slice(2));\n  await main(parsed);\n} catch (err) {\n  if (err.message.startsWith('Unknown argument:')) {\n    console.error(`${err.message}\\nRun with --help to see supported flags.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Wrap script invocations in npm scripts or aliases so flags are defined once","Copy flags from the script's help/README rather than memory","Add a shellcheck'd wrapper that validates flags before calling the script","When adding flags, update parseArgs and docs together"],"tags":["cli","argument-parsing","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"}