affaan-m/ECC · error · Error
must be a positive number
Error message
${flagName} must be a positive number What it means
readPositiveNumber in scripts/loop-status.js converts a flag's string value with Number() and requires the result to be a finite number greater than 0. Non-numeric strings, NaN, Infinity, zero, and negatives all throw this error naming the offending flag.
Solutions
- Pass a plain positive number without units: --interval 30, not 30s.
- Ensure the value is > 0; use a small positive value instead of 0 or a negative number.
- Verify shell variables holding the value are set and numeric.
- Check --help for the expected unit (typically seconds) and valid range.
Example fix
// before node scripts/loop-status.js --interval 30s // after node scripts/loop-status.js --interval 30
Defensive patterns
Strategy: validation
Validate before calling
function assertPositiveInt(v, name) {
const n = Number(v);
if (!Number.isFinite(n) || n <= 0 || !Number.isInteger(n)) {
throw new Error(`${name} must be a positive integer, got: ${JSON.stringify(v)}`);
}
return n;
}
assertPositiveInt(process.env.INTERVAL ?? '30', '--interval'); Type guard
const isPositiveNumber = (v) => typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v)) && Number(v) > 0;
Try / catch
try {
parseArgs(args);
} catch (err) {
if (String(err.message).includes('must be a positive number')) {
console.error(`${err.message} — pass a plain number like 30 (no units, no 0/negative)`);
process.exitCode = 1;
return;
}
throw err;
} Prevention
- Pass bare numbers — strip units like 's' or 'm' before passing
- Never use 0 or negative numbers for interval-style flags
- Validate env-sourced values with Number.isFinite before passing them
- Check --help for each flag's expected unit and range
When it happens
Trigger: Passing --interval abc, --interval 0, --interval -5, or --interval 1e999 (Infinity) to loop-status; also triggered by readPositiveInteger for fractional values routed through it.
Common situations: Typos in numeric values; pasting values with units ('30s', '5m') instead of plain numbers; unset/empty shell variables becoming NaN; intending a 'forever' value with 0 or -1 which the parser rejects.
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
- all overlays must be readable local files
- all takes must be readable local files
- Arguments must not contain NUL bytes.
- asset name must be a simple filename stem (letters, digits…
- At least one guided harness must be selected
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/d942667b33cec635.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/loop-status.js:51
'',
'Examples:',
' node scripts/loop-status.js --json',
' node scripts/loop-status.js --transcript ~/.claude/projects/-repo/session.jsonl'
].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 readPositiveNumber(value, flagName) {
const number = Number(value);
if (!Number.isFinite(number) || number <= 0) {
throw new Error(`${flagName} must be a positive number`);
}
return number;
}
function readPositiveInteger(value, flagName) {
const number = readPositiveNumber(value, flagName);
if (!Number.isInteger(number)) {
throw new Error(`${flagName} must be a positive integer`);
}
return number;
}
function parseArgs(argv) {
const args = argv.slice(2);
const options = {
bashTimeoutSeconds: DEFAULT_BASH_TIMEOUT_SECONDS,
exitCode: false,
home: null,View on GitHub (pinned to 8321021c54)