{"record":{"id":"eaab7d1e5bff29ee","repo":"affaan-m/ECC","slug":"invalid-flagname-value-eaab7d","errorCode":null,"errorMessage":"Invalid ${flagName}: ${value}","messagePattern":"Invalid (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/operator-readiness-dashboard.js","lineNumber":53,"sourceCode":"    '  --use-env-github-token     Keep GITHUB_TOKEN when invoking gh',\n    '  --generated-at <iso>       Override generatedAt for deterministic tests',\n    '  --exit-code                Return 2 when the objective 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 normalizeRelativePrefix(value) {\n  const normalized = String(value || '')\n    .replace(/\\\\/g, '/')\n    .replace(/^\\.\\/+/, '')\n    .replace(/\\/+$/, '');\n  return normalized ? `${normalized}/` : '';\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    allowUntracked: [],\n    exitCode: false,\n    format: 'markdown',","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/operator-readiness-dashboard.js#L35-L71","documentation":"Thrown by parseIntegerFlag in scripts/operator-readiness-dashboard.js when a threshold flag (--max-open-prs, --max-open-issues, --max-dirty-files) cannot be parsed as a finite non-negative integer. The guard rejects NaN, floats, negatives, and any non-numeric string.","triggerScenarios":"Passing `--max-open-prs -5`, `--max-open-prs 3.5`, `--max-open-prs abc`, or `--max-open-prs ''`. Number.parseInt returns NaN for non-numeric input; parseFloat-style decimals fail the Number.isInteger check; negatives fail the `parsed < 0` check.","commonSituations":"Configuring thresholds from an environment variable or CI input that was not validated; passing a decimal where an integer is expected; a leading space or unit suffix (`5pr`) in the value.","solutions":["Provide a non-negative integer: `--max-open-prs 10`.","Round float inputs to integers before passing them in.","If sourcing from env, coerce and validate upstream (e.g. `Math.max(0, Math.floor(Number(val)))`) and fail before the CLI call."],"exampleFix":"// before\nnode scripts/operator-readiness-dashboard.js --max-dirty-files -1\n// after\nnode scripts/operator-readiness-dashboard.js --max-dirty-files 20","handlingStrategy":"type-guard","validationCode":"function normalizeThreshold(raw, name) {\n  const n = Math.floor(Number(raw));\n  if (!Number.isFinite(n) || n < 0 || String(raw) === '') {\n    throw new Error(`Invalid ${name}: ${raw}. Must be a non-negative integer.`);\n  }\n  return n;\n}","typeGuard":"function isThreshold(value) {\n  return typeof value === 'number' && Number.isInteger(value) && value >= 0;\n}","tryCatchPattern":null,"preventionTips":["Coerce env-sourced thresholds with Math.floor and a non-negative guard upstream.","Reject empty strings and decimals before invoking the CLI.","Document each threshold's unit in your wrapper so callers do not guess."],"tags":["cli","operator-dashboard","argument-validation","integer-parsing"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}