{"record":{"id":"66d46124ac56d874","repo":"affaan-m/ECC","slug":"invalid-flagname-value-66d461","errorCode":null,"errorMessage":"Invalid ${flagName}: ${value}","messagePattern":"Invalid (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":61,"sourceCode":"    '  --allow-untracked <path>   Ignore untracked files under path; repeatable',\n    '  --use-env-github-token     Keep GITHUB_TOKEN when invoking gh',\n    '  --exit-code                Return 2 when the audit is not ready',\n    '  --help, -h                 Show this help',\n  ].join('\\n'));\n}\n\nfunction readValue(args, index, flagName) {\n  const value = args[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new Error(`${flagName} requires a value`);\n  }\n  return value;\n}\n\nfunction parseIntegerFlag(value, flagName) {\n  const parsed = Number.parseInt(value, 10);\n  if (!Number.isFinite(parsed) || parsed < 0) {\n    throw new Error(`Invalid ${flagName}: ${value}`);\n  }\n  return parsed;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    allowUntracked: [],\n    exitCode: false,\n    format: 'text',\n    help: false,\n    repos: [],\n    root: path.resolve(process.cwd()),\n    skipGithub: false,\n    thresholds: { ...DEFAULT_THRESHOLDS },\n    useEnvGithubToken: false,\n    writePath: null,\n  };","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/platform-audit.js#L43-L79","documentation":"Thrown by parseIntegerFlag when a threshold flag (--max-open-prs, --max-open-issues, --max-dirty-files) receives a value that is not a finite non-negative integer. The check is `Number.parseInt` plus `Number.isFinite` and `>= 0`, so floats, NaN, negatives, and non-numeric strings all fail. Thresholds gate the audit's pass/fail decision so they must be well-formed.","triggerScenarios":"Passing `--max-open-prs 1.5`, `--max-open-prs -1`, `--max-open-prs abc`, or `--max-open-prs ''`; a value with surrounding text like `10px`; scientific notation that parseInt truncates unexpectedly.","commonSituations":"User copies a default and edits it introducing a typo; env var supplies an empty string; percentage vs absolute-count confusion leading to a decimal.","solutions":["Pass a whole number >= 0: `--max-open-prs 25`.","If the value comes from an env var, validate it before forwarding: only digits, then coerce with Number.","Leave the flag off entirely to keep the DEFAULT_THRESHOLDS (maxOpenPrs / maxOpenIssues / maxDirtyFiles)."],"exampleFix":"# before\nnode scripts/platform-audit.js --max-open-prs 1.5 --max-dirty-files -1\n# after\nnode scripts/platform-audit.js --max-open-prs 2 --max-dirty-files 0","handlingStrategy":"validation","validationCode":"function parseThreshold(value, flagName) {\n  const parsed = Number.parseInt(value, 10);\n  if (!Number.isFinite(parsed) || parsed < 0) {\n    throw new Error(`Invalid ${flagName}: ${value}`);\n  }\n  return parsed;\n}","typeGuard":"function isNonNegativeInt(value) {\n  return typeof value === 'string' && /^(0|[1-9]\\d*)$/.test(value.trim());\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Invalid ')) {\n    console.error(`${err.message}. Threshold flags need a whole number >= 0.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Pass whole numbers >= 0 only — no decimals, no negatives, no units.","If thresholds come from env, validate with a regex before forwarding.","Omit the flag to keep DEFAULT_THRESHOLDS."],"tags":["cli","argument-validation","platform-audit","thresholds"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}