{"record":{"id":"28d068e902fe7423","repo":"affaan-m/ECC","slug":"unknown-option-arg","errorCode":null,"errorMessage":"Unknown option: ${arg}","messagePattern":"Unknown option: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/loop-status.js","lineNumber":121,"sourceCode":"      index += 1;\n    } else if (arg === '--now') {\n      options.now = readValue(args, index, arg);\n      index += 1;\n    } else if (arg === '--exit-code') {\n      options.exitCode = true;\n    } else if (arg === '--watch') {\n      options.watch = true;\n    } else if (arg === '--watch-count') {\n      options.watchCount = readPositiveInteger(readValue(args, index, arg), arg);\n      index += 1;\n    } else if (arg === '--watch-interval-seconds') {\n      options.watchIntervalSeconds = readPositiveNumber(readValue(args, index, arg), arg);\n      index += 1;\n    } else if (arg === '--write-dir') {\n      options.writeDir = readValue(args, index, arg);\n      index += 1;\n    } else {\n      throw new Error(`Unknown option: ${arg}`);\n    }\n  }\n\n  if (options.exitCode && options.watch && options.watchCount === null) {\n    throw new Error('--exit-code with --watch requires --watch-count so the process can exit');\n  }\n\n  return options;\n}\n\nfunction normalizeOptions(options = {}) {\n  return {\n    ...options,\n    bashTimeoutSeconds: options.bashTimeoutSeconds ?? DEFAULT_BASH_TIMEOUT_SECONDS,\n    exitCode: Boolean(options.exitCode),\n    limit: options.limit ?? DEFAULT_LIMIT,\n    transcriptPaths: options.transcriptPaths || [],\n    watch: Boolean(options.watch),","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/loop-status.js#L103-L139","documentation":"parseArgs in scripts/loop-status.js only recognizes a fixed set of CLI options; any argument not matching a known flag falls into the else branch and throws 'Unknown option: <arg>'. This is a strict allowlist parser: typos, renamed flags, or extra positional arguments are rejected rather than ignored.","triggerScenarios":"Running `node scripts/loop-status.js --wathc` (typo), `--verbose` (unsupported flag), or passing a stray positional like `node scripts/loop-status.js foo`.","commonSituations":"Typo in a flag name, copying flags from a different script (e.g. memory.js flags like --once), old flags removed in a script update, or forgetting that the script takes no positional arguments.","solutions":["Check the flag spelling against the accepted options in parseArgs (--watch, --watch-count, --watch-interval-seconds, --write-dir, --exit-code, --now, etc.) and fix the typo.","Run `node scripts/loop-status.js --help` (or read the script header) to list valid flags.","Remove any positional/extra arguments — the parser expects only known flags.","If a flag was renamed in a recent update, migrate to the new flag name."],"exampleFix":"// before\nnode scripts/loop-status.js --watch-cout 5\n// after\nnode scripts/loop-status.js --watch-count 5","handlingStrategy":"validation","validationCode":"const KNOWN = new Set(['--watch','--watch-count','--watch-interval-seconds','--write-dir','--exit-code','--now']);\nconst bad = args.filter(a => a.startsWith('--') && !KNOWN.has(a));\nif (bad.length) throw new Error(`Unknown option(s): ${bad.join(', ')}`);","typeGuard":"const isKnownFlag = (arg, known) => known.has(arg);","tryCatchPattern":"try { run(args); } catch (e) { if (e.message.startsWith('Unknown option:')) { console.error(`${e.message} — run with --help for valid flags`); process.exitCode = 2; } else throw e; }","preventionTips":["Keep a copy of the accepted flags in your wrapper scripts","Lint CLI invocations in CI against the known flag set","Avoid copying flags between different ECC scripts"],"tags":["cli","argument-parsing","unknown-option"],"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"}