{"record":{"id":"8528e0cd138ece84","repo":"affaan-m/ECC","slug":"unknown-argument-arg-8528e0","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":114,"sourceCode":"  }\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n    if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n    } else if (arg === '--json') {\n      parsed.json = true;\n    } else if (VALUE_FLAGS.has(arg)) {\n      const value = args[index + 1];\n      if (!value || value.startsWith('--')) {\n        throw new Error(`Missing value for ${arg}`);\n      }\n      assignOption(parsed, arg, value);\n      index += 1;\n    } else if (!arg.startsWith('-')) {\n      parsed.positionals.push(arg);\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  return parsed;\n}\n\nfunction parseMetadataJson(value) {\n  if (value === undefined || value === null) {\n    return null;\n  }\n\n  try {\n    return JSON.parse(value);\n  } catch (error) {\n    throw new Error(`Invalid --metadata-json: ${error.message}`);\n  }\n}\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/work-items.js#L96-L132","documentation":"Thrown by scripts/work-items.js parseArgs when a token starts with '-' but is not --help, -h, --json, and not a member of VALUE_FLAGS. Any hyphen-prefixed token that is not a recognized option is rejected; bare positional tokens (like a subcommand or an id) are accepted into positionals and do not trigger this. This is the work-items counterpart of the unknown-argument guard in status.js and uninstall.js.","triggerScenarios":"`node scripts/work-items.js list --verbose`; `node scripts/work-items.js upsert --description \"x\"` (--description is not a supported flag); `--json-output` (correct is --json).","commonSituations":"Typos in flag names; passing a flag from another ECC script that work-items does not support; a version mismatch where a flag was renamed; assuming a generic flag like --verbose exists.","solutions":["Run `node scripts/work-items.js --help` to see the accepted flags per subcommand.","Correct the flag spelling or remove the unsupported option.","Confirm the flag belongs to work-items.js and not to a sibling script (status.js, uninstall.js)."],"exampleFix":"// before\nnode scripts/work-items.js list --verbose\n\n// after\nnode scripts/work-items.js list --json","handlingStrategy":"validation","validationCode":"const KNOWN = new Set(['--help','-h','--json','--as','--db','--github-repo','--id','--limit','--metadata-json','--owner','--priority','--repo','--repo-root','--session','--session-id','--source','--source-id','--status','--title','--url']);\nfunction validateWorkItemsArgs(argv) {\n  for (const tok of argv) {\n    if (tok.startsWith('-') && !KNOWN.has(tok)) {\n      throw new Error(`work-items.js does not accept: ${tok}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `node scripts/work-items.js --help` to enumerate valid flags per subcommand.","Do not reuse flags from status.js/uninstall.js on work-items.js without checking.","Validate assembled argv in a helper before spawning the process."],"tags":["cli","argument-parsing","work-items","validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}