affaan-m/ECC · error · Error
Invalid ${flagName}: ${value}
Error message
Invalid ${flagName}: ${value} What it means
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.
Source
Thrown at scripts/platform-audit.js:61
' --allow-untracked <path> Ignore untracked files under path; repeatable',
' --use-env-github-token Keep GITHUB_TOKEN when invoking gh',
' --exit-code Return 2 when the audit is not ready',
' --help, -h Show this help',
].join('\n'));
}
function readValue(args, index, flagName) {
const value = args[index + 1];
if (!value || value.startsWith('--')) {
throw new Error(`${flagName} requires a value`);
}
return value;
}
function parseIntegerFlag(value, flagName) {
const parsed = Number.parseInt(value, 10);
if (!Number.isFinite(parsed) || parsed < 0) {
throw new Error(`Invalid ${flagName}: ${value}`);
}
return parsed;
}
function parseArgs(argv) {
const args = argv.slice(2);
const parsed = {
allowUntracked: [],
exitCode: false,
format: 'text',
help: false,
repos: [],
root: path.resolve(process.cwd()),
skipGithub: false,
thresholds: { ...DEFAULT_THRESHOLDS },
useEnvGithubToken: false,
writePath: null,
};View on GitHub (pinned to 01e15490f0)
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).
Example fix
# before node scripts/platform-audit.js --max-open-prs 1.5 --max-dirty-files -1 # after node scripts/platform-audit.js --max-open-prs 2 --max-dirty-files 0
Defensive patterns
Strategy: validation
Validate before calling
function parseThreshold(value, flagName) {
const parsed = Number.parseInt(value, 10);
if (!Number.isFinite(parsed) || parsed < 0) {
throw new Error(`Invalid ${flagName}: ${value}`);
}
return parsed;
} Type guard
function isNonNegativeInt(value) {
return typeof value === 'string' && /^(0|[1-9]\d*)$/.test(value.trim());
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message.startsWith('Invalid ')) {
console.error(`${err.message}. Threshold flags need a whole number >= 0.`);
process.exit(2);
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${flagName} requires a value
- Unknown argument: ${arg}
- Invalid format: ${parsed.format}. Use text, json, or markdow
- --write requires --json, --markdown, or --format json|markdo
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/66d46124ac56d874.
Report an issue: GitHub.