{"record":{"id":"d3c2a7f7699da5f7","repo":"affaan-m/ECC","slug":"unknown-argument-arg-d3c2a7","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/codex/check-plugin-cache.js","lineNumber":72,"sourceCode":"  const optionKeys = {\n    '--codex-home': 'codexHome',\n    '--plugin-dir': 'pluginDir',\n    '--marketplace': 'marketplace',\n    '--plugin': 'plugin',\n    '--version': 'version',\n  };\n  let parsed = {};\n\n  for (let index = 0; index < argv.length; index += 1) {\n    const arg = argv[index];\n    if (arg === '--help' || arg === '-h') {\n      parsed = { ...parsed, help: true };\n      continue;\n    }\n\n    const key = optionKeys[arg];\n    if (!key) {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n\n    const value = argv[index + 1];\n    if (!value || value.startsWith('--')) {\n      throw new Error(`Missing value for ${arg}`);\n    }\n    index += 1;\n\n    parsed = { ...parsed, [key]: value };\n  }\n\n  const options = { ...defaults, ...parsed };\n  return {\n    ...options,\n    marketplace: validateCacheSegment('--marketplace', options.marketplace),\n    plugin: validateCacheSegment('--plugin', options.plugin),\n    version: validateCacheSegment('--version', options.version),\n    codexHome: path.resolve(options.codexHome),","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/codex/check-plugin-cache.js#L54-L90","documentation":"The argument parser in check-plugin-cache.js uses a lookup table (optionKeys) that maps only --codex-home, --plugin-dir, --marketplace, --plugin, and --version to their option keys. Any argument not in this table and not --help/-h triggers this error. The parser is intentionally strict — there are no positional arguments.","triggerScenarios":"Passing an unsupported flag like --verbose, --debug, or --output; using a flag from a different tool; or a typo such as --plugn instead of --plugin.","commonSituations":"Running the script with flags from memory that don't exist; CI configurations referencing removed flags; shell aliases that inject unexpected arguments.","solutions":["Run `node scripts/codex/check-plugin-cache.js --help` to see the accepted flags","Check for typos in flag names","Remove any flags not listed in the usage output"],"exampleFix":"// before\nnode scripts/codex/check-plugin-cache.js --verbose\n// after\nnode scripts/codex/check-plugin-cache.js --help","handlingStrategy":"validation","validationCode":"// Pre-validate arguments against the accepted flag set\nconst ACCEPTED = new Set(['--help', '-h', '--codex-home', '--plugin-dir', '--marketplace', '--plugin', '--version']);\nconst argv = process.argv.slice(2);\nfor (const arg of argv) {\n  if (arg.startsWith('--') && !ACCEPTED.has(arg)) {\n    console.error(`Unknown argument: ${arg}`);\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const options = parseArgs(process.argv.slice(2));\n} catch (error) {\n  if (error.message.startsWith('Unknown argument:')) {\n    console.error(error.message);\n    usage();\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["Run --help to list accepted flags before constructing complex commands","Keep a documented list of flags used in CI configurations","When updating ECC, diff the usage() output to catch removed or renamed flags"],"tags":["cli","argument-parsing","codex"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}