{"record":{"id":"0d31d6ef5a012f24","repo":"affaan-m/ECC","slug":"unknown-argument-arg-0d31d6","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/release-approval-gate.js","lineNumber":158,"sourceCode":"    }\n\n    if (arg.startsWith('--format=')) {\n      parsed.format = arg.slice('--format='.length).toLowerCase();\n      continue;\n    }\n\n    if (arg === '--root') {\n      parsed.root = path.resolve(readArgValue(args, index, arg));\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${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 readText(rootDir, relativePath) {\n  try {\n    return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');\n  } catch (_error) {\n    return '';\n  }\n}\n\nfunction fileExists(rootDir, relativePath) {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/release-approval-gate.js#L140-L176","documentation":"Thrown at the end of release-approval-gate's parseArgs loop when a token matched none of --help/-h, --format(+==), --json, --root(+==). The parser is strict because the gate's verdict must be deterministic and tied to known inputs only.","triggerScenarios":"A typo like `--formatt`; a positional path instead of `--root`; a flag from platform-audit or preview-pack-smoke that this gate does not share; shell glob injecting a token.","commonSituations":"User assumes shared flag sets across ECC gates; version mismatch; stray token from unquoted shell expansion.","solutions":["Run `--help` to confirm the accepted flags for this installed version.","Pass repo via `--root=<dir>`; format via `--json` or `--format=json`.","Quote all arguments and verify no expansion produced extra tokens."],"exampleFix":"# before\nnode scripts/release-approval-gate.js --fromat json\n# after\nnode scripts/release-approval-gate.js --format json","handlingStrategy":"validation","validationCode":"const GATE_FLAGS = new Set(['--help','-h','--format','--json','--root']);\nfunction isGateFlag(token) {\n  const base = token.split('=')[0];\n  return GATE_FLAGS.has(base);\n}","typeGuard":"function isKnownGateFlag(token) {\n  const base = token.startsWith('--') ? token.split('=')[0] : token;\n  return GATE_FLAGS.has(base);\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Unknown argument')) {\n    console.error(`${err.message}. release-approval-gate only accepts --format and --root.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Only --format and --root are accepted; do not copy flags from other gates.","Run --help for the authoritative list.","Quote arguments and verify no shell expansion added tokens."],"tags":["cli","argument-validation","release-approval-gate"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}