affaan-m/ECC · error · Error

Invalid ${flagName}: ${value}

Error message

Invalid ${flagName}: ${value}

What it means

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.

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 01e15490f0)

Solutions

  1. Provide a non-negative integer: `--max-open-prs 10`.
  2. Round float inputs to integers before passing them in.
  3. If sourcing from env, coerce and validate upstream (e.g. `Math.max(0, Math.floor(Number(val)))`) and fail before the CLI call.

Example fix

// before
node scripts/operator-readiness-dashboard.js --max-dirty-files -1
// after
node scripts/operator-readiness-dashboard.js --max-dirty-files 20
Defensive patterns

Strategy: type-guard

Validate before calling

function normalizeThreshold(raw, name) {
  const n = Math.floor(Number(raw));
  if (!Number.isFinite(n) || n < 0 || String(raw) === '') {
    throw new Error(`Invalid ${name}: ${raw}. Must be a non-negative integer.`);
  }
  return n;
}

Type guard

function isThreshold(value) {
  return typeof value === 'number' && Number.isInteger(value) && value >= 0;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/eaab7d1e5bff29ee. Report an issue: GitHub.