{"record":{"id":"d942667b33cec635","repo":"affaan-m/ECC","slug":"flagname-must-be-a-positive-number","errorCode":null,"errorMessage":"${flagName} must be a positive number","messagePattern":"(.+?) must be a positive number","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/loop-status.js","lineNumber":51,"sourceCode":"    '',\n    'Examples:',\n    '  node scripts/loop-status.js --json',\n    '  node scripts/loop-status.js --transcript ~/.claude/projects/-repo/session.jsonl'\n  ].join('\\n'));\n}\n\nfunction readValue(args, index, flagName) {\n  const value = args[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new Error(`${flagName} requires a value`);\n  }\n  return value;\n}\n\nfunction readPositiveNumber(value, flagName) {\n  const number = Number(value);\n  if (!Number.isFinite(number) || number <= 0) {\n    throw new Error(`${flagName} must be a positive number`);\n  }\n  return number;\n}\n\nfunction readPositiveInteger(value, flagName) {\n  const number = readPositiveNumber(value, flagName);\n  if (!Number.isInteger(number)) {\n    throw new Error(`${flagName} must be a positive integer`);\n  }\n  return number;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const options = {\n    bashTimeoutSeconds: DEFAULT_BASH_TIMEOUT_SECONDS,\n    exitCode: false,\n    home: null,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/loop-status.js#L33-L69","documentation":"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.","triggerScenarios":"Passing --interval abc, --interval 0, --interval -5, or --interval 1e999 (Infinity) to loop-status; also triggered by readPositiveInteger for fractional values routed through it.","commonSituations":"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.","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."],"exampleFix":"// before\nnode scripts/loop-status.js --interval 30s\n// after\nnode scripts/loop-status.js --interval 30","handlingStrategy":"validation","validationCode":"function assertPositiveInt(v, name) {\n  const n = Number(v);\n  if (!Number.isFinite(n) || n <= 0 || !Number.isInteger(n)) {\n    throw new Error(`${name} must be a positive integer, got: ${JSON.stringify(v)}`);\n  }\n  return n;\n}\nassertPositiveInt(process.env.INTERVAL ?? '30', '--interval');","typeGuard":"const isPositiveNumber = (v) => typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v)) && Number(v) > 0;","tryCatchPattern":"try {\n  parseArgs(args);\n} catch (err) {\n  if (String(err.message).includes('must be a positive number')) {\n    console.error(`${err.message} — pass a plain number like 30 (no units, no 0/negative)`);\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["cli","validation","numbers"],"backgroundTag":"invalid-flag-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}