{"record":{"id":"2d57b3e68a3af636","repo":"affaan-m/ECC","slug":"unknown-argument-flag","errorCode":null,"errorMessage":"Unknown argument: ${flag}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":80,"sourceCode":"\nfunction assignOption(options, flag, value) {\n  if (flag === '--as') options.claimAs = value;\n  else if (flag === '--db') options.dbPath = value;\n  else if (flag === '--github-repo') options.githubRepo = value;\n  else if (flag === '--id') options.id = value;\n  else if (flag === '--limit') options.limit = value;\n  else if (flag === '--metadata-json') options.metadataJson = value;\n  else if (flag === '--owner') options.owner = value;\n  else if (flag === '--priority') options.priority = value;\n  else if (flag === '--repo' && options.command === 'sync-github') options.githubRepo = value;\n  else if (flag === '--repo' || flag === '--repo-root') options.repoRoot = value;\n  else if (flag === '--session' || flag === '--session-id') options.sessionId = value;\n  else if (flag === '--source') options.source = value;\n  else if (flag === '--source-id') options.sourceId = value;\n  else if (flag === '--status') options.status = value;\n  else if (flag === '--title') options.title = value;\n  else if (flag === '--url') options.url = value;\n  else throw new Error(`Unknown argument: ${flag}`);\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    command: 'list',\n    dbPath: null,\n    help: false,\n    json: false,\n    limit: 20,\n    positionals: []\n  };\n\n  if (args[0] && !args[0].startsWith('-')) {\n    parsed.command = args.shift();\n  }\n\n  for (let index = 0; index < args.length; index += 1) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/work-items.js#L62-L98","documentation":"work-items.js assignOption maps a known flag to an option on the parsed object via a long if/else chain; if the flag matches none of the recognized options, the terminal else throws 'Unknown argument: <flag>'. This is the value-flag level allowlist check (separate from parseArgs' own unknown-flag branch).","triggerScenarios":"parseArgs forwards a flag listed in VALUE_FLAGS to assignOption that the chain doesn't handle (e.g. a newly added VALUE_FLAGS entry missed in assignOption), or in practice a caller passes an unsupported option like `--foo bar`.","commonSituations":"Flags remembered from other ECC scripts (--target, --action) used against work-items; docs drift where a flag was renamed (e.g. --session-id vs --session); editing the script and adding a flag to VALUE_FLAGS without adding the assignOption branch.","solutions":["Use a flag supported by assignOption (see the chain: --session/--session-id, --source, --source-id, --status, --title, --url, etc.)","Check spelling and aliases — some flags have two accepted forms","Run with --help to list supported flags for the chosen command","If maintaining the script, add the missing `else if` branch for any flag added to VALUE_FLAGS"],"exampleFix":"// before\nnode scripts/work-items.js add --titel \"Fix bug\"\n// after\nnode scripts/work-items.js add --title \"Fix bug\"","handlingStrategy":"validation","validationCode":"const KNOWN_FLAGS = new Set(['--session','--session-id','--source','--source-id','--status','--title','--url' /* plus others from assignOption */]);\nconst unknown = process.argv.slice(2).filter(a => a.startsWith('--') && !KNOWN_FLAGS.has(a) && a !== '--help' && a !== '--json');\nif (unknown.length > 0) throw new Error(`Unknown argument(s): ${unknown.join(', ')}`);","typeGuard":"function isKnownWorkItemsFlag(flag) {\n  return VALUE_FLAGS.has(flag) || flag === '--help' || flag === '--json';\n}","tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Unknown argument:')) {\n    console.error(`${err.message}. Run 'work-items --help' for the supported flags.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Run `work-items --help` to enumerate flags before composing commands","Check spelling of long flags (e.g. --title not --titel)","Use the documented alias (--session vs --session-id) that your script version supports","If editing the script, keep VALUE_FLAGS and assignOption branches in sync"],"tags":["cli","arguments","allowlist"],"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"}