{"record":{"id":"b90902cff8ea18d2","repo":"affaan-m/ECC","slug":"unknown-argument-arg-b90902","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/harness-audit.js","lineNumber":121,"sourceCode":"    }\n\n    if (arg.startsWith('--format=')) {\n      parsed.format = arg.split('=')[1].toLowerCase();\n      continue;\n    }\n\n    if (arg.startsWith('--scope=')) {\n      parsed.scope = normalizeScope(arg.split('=')[1]);\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\n      continue;\n    }\n\n    if (arg.startsWith('-')) {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n\n    parsed.scope = normalizeScope(arg);\n  }\n\n  if (!['text', 'json'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text or json.`);\n  }\n\n  return parsed;\n}\n\nfunction fileExists(rootDir, relativePath) {\n  return fs.existsSync(path.join(rootDir, relativePath));\n}\n\nfunction readText(rootDir, relativePath) {\n  return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/harness-audit.js#L103-L139","documentation":"The CLI argument parser in harness-audit.js only recognizes --help/-h, --format (and --format=), --scope (and --scope=), --root (and --root=), plus a bare scope token. Any other token that begins with '-' is treated as an unsupported flag and rejected outright. The tool will not guess or ignore unknown flags.","triggerScenarios":"Passing --json (which is valid in install-plan.js but NOT here), --verbose, -v, --output report.txt, or a typo such as --scpoe=repo. Also triggered by flags copied from a different ECC subcommand.","commonSituations":"Copying flags from another ECC script's help text, using an outdated flag renamed in a newer version, or a shell autocomplete inserting the wrong option.","solutions":["Run node scripts/harness-audit.js --help to see the accepted flag set","Remove the unrecognized flag from the command line","For machine-readable output use --format=json (there is no --json flag here)"],"exampleFix":"// before\nnode scripts/harness-audit.js --json\n// after\nnode scripts/harness-audit.js --format=json","handlingStrategy":"validation","validationCode":"const KNOWN = new Set(['--help','-h','--format','--scope','--root']);\nconst startsKnown = (a) => a.startsWith('--format=') || a.startsWith('--scope=') || a.startsWith('--root=');\nfor (const a of argv) {\n  if (a.startsWith('-') && !KNOWN.has(a) && !startsKnown(a)) {\n    throw new Error(`Unsupported harness-audit flag: ${a}`);\n  }\n}","typeGuard":"function isKnownHarnessAuditFlag(arg) {\n  if (!arg.startsWith('-')) return true; // bare scope token\n  return ['--help','-h','--format','--scope','--root'].includes(arg)\n    || arg.startsWith('--format=')\n    || arg.startsWith('--scope=')\n    || arg.startsWith('--root=');\n}","tryCatchPattern":"try { main(); }\ncatch (err) {\n  if (/^Unknown argument:/.test(err.message)) {\n    console.error(`${err.message}\\nRun: node scripts/harness-audit.js --help`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Always cross-check flags against --help before scripting them","Do not assume flags are shared across ECC subcommands","Pin wrapper scripts to a help-output assertion in CI so flag drift is caught"],"tags":["cli","argument-parsing","harness-audit"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}