{"record":{"id":"8528e0cd138ece84","repo":"affaan-m/ECC","slug":"unknown-argument-arg-8528e0","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/work-items.js#L96-L132","documentation":"parseArgs classifies each token: --help, --json, VALUE_FLAGS, or a non-dash positional. Any remaining token starting with '-' is an unrecognized flag and throws 'Unknown argument: <arg>'. This is the top-level flag allowlist, distinct from assignOption's unknown-flag error (676).","triggerScenarios":"Passing an unsupported dash-flag like `node scripts/work-items.js list --verbose` or `--limit 5`, or mistyped supported flags (e.g. `--jsoin`), or single-dash short forms like `-t` that aren't registered.","commonSituations":"Assuming Unix-style short flags exist; flags copied from other tools' CLIs; running an older version of the script that lacks a newer flag; shell aliases expanding into unexpected tokens.","solutions":["Remove or correct the unsupported flag; check `--help` output for the accepted set","Replace short flags with the long forms the script defines","Verify you're running the intended script — flag sets differ across scripts/ files","Update the repo if a documented flag is missing from your checkout"],"exampleFix":"// before\nnode scripts/work-items.js list --verbose\n// after\nnode scripts/work-items.js list","handlingStrategy":"validation","validationCode":"const flags = process.argv.slice(2).filter(a => a.startsWith('-'));\nconst POSITIONALS_OK = true; // non-dash tokens are fine\nconst unknownFlags = flags.filter(a => a !== '--help' && a !== '--json' && !VALUE_FLAGS.has(a));\nif (unknownFlags.length > 0) throw new Error(`Unknown argument(s): ${unknownFlags.join(', ')}`);","typeGuard":"function isRecognizedToken(arg) {\n  return !arg.startsWith('-') || arg === '--help' || arg === '--json' || VALUE_FLAGS.has(arg);\n}","tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Unknown argument:')) {\n    console.error(`${err.message}. Short flags are not supported; use long forms.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Prefer long flags exactly as documented; no single-dash shortcuts","Validate wrapper scripts' argv construction with a dry run","Diff your command against `--help` output when copying from other tools","Pull latest repo if a documented flag is rejected by your checkout"],"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"}