affaan-m/ECC · error · Error
Invalid limit: ${value}
Error message
Invalid limit: ${value} What it means
Thrown by scripts/normalizeLimit in scripts/work-items.js when the --limit value cannot be parsed as a finite positive integer. The function runs `Number.parseInt(value, 10)` and rejects NaN, Infinity, zero, and negatives. --limit is used both for the local list query depth and (for sync-github) as the row cap passed to `gh pr list` / `gh issue list`, so it must be a usable count.
Source
Thrown at scripts/work-items.js:140
if (value === undefined || value === null) {
return null;
}
try {
return JSON.parse(value);
} catch (error) {
throw new Error(`Invalid --metadata-json: ${error.message}`);
}
}
function resolveWorkItemId(options) {
return options.id || options.positionals[0] || null;
}
function normalizeLimit(value) {
const parsed = Number.parseInt(value, 10);
if (!Number.isFinite(parsed) || parsed <= 0) {
throw new Error(`Invalid limit: ${value}`);
}
return parsed;
}
function runGhJson(args) {
const shimPath = process.env.ECC_GH_SHIM;
const command = shimPath ? process.execPath : 'gh';
const commandArgs = shimPath ? [shimPath, ...args] : args;
const displayCommand = shimPath ? `node ${shimPath} ${args.join(' ')}` : `gh ${args.join(' ')}`;
const result = spawnSync(command, commandArgs, {
encoding: 'utf8',
maxBuffer: 10 * 1024 * 1024
});
if (result.error) {
throw new Error(`Failed to run gh: ${result.error.message}`);
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Pass a positive integer: `--limit 20`.
- If you want the default, omit --limit (default is 20 for list).
- Ensure the count variable is a positive integer before constructing the flag.
Example fix
// before node scripts/work-items.js list --limit abc // after node scripts/work-items.js list --limit 20
Defensive patterns
Strategy: validation
Validate before calling
function normalizeLimit(raw) {
const n = Number.parseInt(raw, 10);
if (!Number.isFinite(n) || n <= 0) return null; // let caller omit --limit
return n;
}
const args = ['list'];
const limit = normalizeLimit(process.env.ECC_ITEMS_LIMIT);
if (limit) args.push('--limit', String(limit)); Type guard
function isPositiveInt(value) {
const n = Number.parseInt(value, 10);
return Number.isFinite(n) && n > 0 && String(n) === String(value).trim();
} Prevention
- Parse limit env vars once and validate before flag construction.
- Omit --limit (default 20) rather than pass 0 or a non-number.
- Reject empty strings explicitly so they do not become NaN downstream.
When it happens
Trigger: `node scripts/work-items.js list --limit abc`; `--limit 0`; `--limit -5`; `--limit 2.5` (parseInt yields 2 which is positive, so this passes — the reject is only for non-finite or <= 0).
Common situations: A configurable count variable defaulting to an empty string or a label; passing a percentage or a float where a count is expected; a wrapper that passes 0 to mean 'no limit' (this CLI does not support that).
Related errors
- Missing value for ${arg}
- Unknown argument: ${arg}
- Invalid --metadata-json: ${error.message}
- ${label} must be a positive integer
- Unknown install target: ${parsed.target}. Expected one of ${
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/bce8a3f5f60b0c6d.
Report an issue: GitHub.