affaan-m/ECC · error · Error
Invalid
Error message
Invalid ${flagName}: ${value} What it means
parseIntegerFlag parses a CLI flag value as a non-negative base-10 integer (e.g. for limits, ports, or refresh intervals). If parseInt yields NaN/Infinity or a negative number, it throws this error naming the flag and the offending raw value. It guarantees downstream code only ever receives a valid non-negative integer.
Solutions
- Pass a plain non-negative integer, e.g. --port 8080 or --limit 20.
- Strip units from the value (500ms -> 500) or fix the shell variable.
- Check for sign/typo issues, e.g. -5 -> 5, 808o -> 8080.
- In scripts, validate numerics before interpolation: `--limit "${LIMIT:?must be set}"` and ensure it's an integer.
Example fix
// before node scripts/operator-readiness-dashboard.js --port 808o // after node scripts/operator-readiness-dashboard.js --port 8080
Defensive patterns
Strategy: validation
Validate before calling
const n = Number.parseInt(raw, 10);
if (!Number.isFinite(n) || n < 0 || String(n) !== raw.trim()) throw new Error(`--port expects a non-negative integer, got: ${raw}`); Type guard
const isNonNegativeInt = (v) => typeof v === 'string' && /^\d+$/.test(v.trim());
Try / catch
try {
runDashboard(argv);
} catch (err) {
if (err.message.startsWith('Invalid ')) {
console.error('Pass a plain non-negative integer for integer flags (no units, no signs).');
} else throw err;
} Prevention
- Pass integers without units (500 not 500ms) or signs.
- Watch for lookalike characters (808o vs 8080).
- Validate env-sourced numeric variables before interpolation.
- Prefer building argv as typed arrays so values keep their intended types.
When it happens
Trigger: Passing `--port abc`, `--limit -5`, `--interval 3.5.3`, or an empty value to any integer flag wired through parseIntegerFlag in parseArgs.
Common situations: Typos like `--port 808o` (letter o); negative numbers where only counts make sense; environment variables interpolated as empty or containing units like `500ms`; decimal values where integers are required.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- Invalid format: . Use text or json.
- Agents directory not found
- --all-harnesses and --harness are mutually exclusive.
- all overlays must be readable local files
- all takes must be readable local files
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/eaab7d1e5bff29ee.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/operator-readiness-dashboard.js:53
' --use-env-github-token Keep GITHUB_TOKEN when invoking gh',
' --generated-at <iso> Override generatedAt for deterministic tests',
' --exit-code Return 2 when the objective 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 normalizeRelativePrefix(value) {
const normalized = String(value || '')
.replace(/\\/g, '/')
.replace(/^\.\/+/, '')
.replace(/\/+$/, '');
return normalized ? `${normalized}/` : '';
}
function parseArgs(argv) {
const args = argv.slice(2);
const parsed = {
allowUntracked: [],
exitCode: false,
format: 'markdown',View on GitHub (pinned to 8321021c54)