{"record":{"id":"26c1fbe60b87fcb8","repo":"affaan-m/ECC","slug":"unknown-argument-arg-26c1fb","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/discussion-audit.js","lineNumber":141,"sourceCode":"      continue;\n    }\n\n    if (arg.startsWith('--first=')) {\n      parsed.first = parseIntegerFlag(arg.slice('--first='.length), '--first');\n      continue;\n    }\n\n    if (arg === '--use-env-github-token') {\n      parsed.useEnvGithubToken = true;\n      continue;\n    }\n\n    if (arg === '--exit-code') {\n      parsed.exitCode = true;\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json', 'markdown'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);\n  }\n\n  if (parsed.writePath && parsed.format === 'text') {\n    throw new Error('--write requires --json, --markdown, or --format json|markdown');\n  }\n\n  return parsed;\n}\n\nfunction buildReport(options) {\n  const repos = options.repos.length > 0 ? options.repos : DEFAULT_REPOS;\n  const repoReports = repos.map(repo => {\n    try {\n      return {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/discussion-audit.js#L123-L159","documentation":"The argument parser in discussion-audit.js has an explicit list of recognized flags: --help/-h, --format (and --format=), --json, --markdown, --write (and --write=), --repo (and --repo=), --first (and --first=), --use-env-github-token, and --exit-code. Any token that does not match one of these patterns falls through to the throw at line 141. There are no positional arguments accepted.","triggerScenarios":"Passing an unsupported flag like --verbose or --output; using a flag from another script; a typo such as --exi-code instead of --exit-code; or passing a positional argument.","commonSituations":"Confusing flags across different ECC scripts; CI configurations with stale flags from older versions; copy-paste from documentation for a different tool.","solutions":["Run `node scripts/discussion-audit.js --help` to see all accepted flags","Check for typos in flag names","Use the --flag=value syntax for unambiguous parsing"],"exampleFix":"// before\nnode scripts/discussion-audit.js --verbose\n// after\nnode scripts/discussion-audit.js --exit-code --format json","handlingStrategy":"validation","validationCode":"// Pre-validate all dash-prefixed arguments\nconst ACCEPTED_PREFIXES = ['--format=', '--write=', '--repo=', '--first='];\nconst ACCEPTED_FLAGS = new Set(['--help', '-h', '--format', '--json', '--markdown', '--write', '--repo', '--first', '--use-env-github-token', '--exit-code']);\nconst argv = process.argv.slice(2);\nfor (const arg of argv) {\n  if (arg.startsWith('--') && !ACCEPTED_FLAGS.has(arg) && !ACCEPTED_PREFIXES.some(p => arg.startsWith(p))) {\n    console.error(`Unknown argument: ${arg}`);\n    usage();\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\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":["discussion-audit.js has no positional arguments — every token must be a recognized flag","Run --help to see all accepted flags and their value requirements","Use --flag=value syntax for unambiguous parsing"],"tags":["cli","argument-parsing","discussion-audit"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}