{"record":{"id":"2d57b3e68a3af636","repo":"affaan-m/ECC","slug":"unknown-argument-flag","errorCode":null,"errorMessage":"Unknown argument: ${flag}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/work-items.js#L62-L98","documentation":"Thrown by scripts/assignOption in scripts/work-items.js if a flag that is a member of the VALUE_FLAGS set reaches the final else branch — meaning it was caught by `VALUE_FLAGS.has(arg)` in parseArgs but has no corresponding handler in assignOption's if-else chain. In the current code every VALUE_FLAGS entry has a handler, so this throw is a defensive invariant guard: it exists to catch a future edit that adds a flag to VALUE_FLAGS without adding its assignment branch. It is effectively unreachable under the present flag set.","triggerScenarios":"Not triggerable through normal CLI use in the current version. Would only fire if a developer added an entry to the VALUE_FLAGS set (lines 9-27) but forgot to add a matching `else if` branch in assignOption, then passed that new flag on the command line.","commonSituations":"A maintainer extending work-items.js with a new value flag (e.g. --label) who updates VALUE_FLAGS but not assignOption; this error is the safety net that makes the omission loud during testing of the new flag.","solutions":["If you are extending work-items.js, ensure every new entry in VALUE_FLAGS has a corresponding branch in assignOption.","If you hit this as an end user, you are likely on a build where a flag was half-wired; report it or pin to a known-good ECC version.","Run the work-items test suite after adding a flag to confirm assignOption is covered."],"exampleFix":"// before (flag added to VALUE_FLAGS but not handled)\nconst VALUE_FLAGS = new Set([..., '--label']);\n// assignOption has no branch for --label -> throws\n\n// after\nelse if (flag === '--label') options.label = value;","handlingStrategy":"validation","validationCode":"// For maintainers: keep VALUE_FLAGS and assignOption in sync\nconst VALUE_FLAGS = require('./work-items-flags'); // single source of truth\nfunction assertAssignOptionCoversAll() {\n  // each VALUE_FLAGS entry must have a branch in assignOption\n  const sample = [...VALUE_FLAGS];\n  const opts = {};\n  for (const flag of sample) {\n    assignOption(opts, flag, 'x'); // throws 472 if a branch is missing\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a flag to VALUE_FLAGS, add the assignOption branch in the same edit.","Add a unit test that calls assignOption for every VALUE_FLAGS member.","Treat the line-80 throw as a build-time tripwire, not a runtime path."],"tags":["cli","argument-parsing","work-items","defensive","invariant"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}