{"record":{"id":"bce8a3f5f60b0c6d","repo":"affaan-m/ECC","slug":"invalid-limit-value-bce8a3","errorCode":null,"errorMessage":"Invalid limit: ${value}","messagePattern":"Invalid limit: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":140,"sourceCode":"  if (value === undefined || value === null) {\n    return null;\n  }\n\n  try {\n    return JSON.parse(value);\n  } catch (error) {\n    throw new Error(`Invalid --metadata-json: ${error.message}`);\n  }\n}\n\nfunction resolveWorkItemId(options) {\n  return options.id || options.positionals[0] || null;\n}\n\nfunction normalizeLimit(value) {\n  const parsed = Number.parseInt(value, 10);\n  if (!Number.isFinite(parsed) || parsed <= 0) {\n    throw new Error(`Invalid limit: ${value}`);\n  }\n  return parsed;\n}\n\nfunction runGhJson(args) {\n  const shimPath = process.env.ECC_GH_SHIM;\n  const command = shimPath ? process.execPath : 'gh';\n  const commandArgs = shimPath ? [shimPath, ...args] : args;\n  const displayCommand = shimPath ? `node ${shimPath} ${args.join(' ')}` : `gh ${args.join(' ')}`;\n  const result = spawnSync(command, commandArgs, {\n    encoding: 'utf8',\n    maxBuffer: 10 * 1024 * 1024\n  });\n\n  if (result.error) {\n    throw new Error(`Failed to run gh: ${result.error.message}`);\n  }\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/work-items.js#L122-L158","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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).","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."],"exampleFix":"// before\nnode scripts/work-items.js list --limit abc\n\n// after\nnode scripts/work-items.js list --limit 20","handlingStrategy":"validation","validationCode":"function normalizeLimit(raw) {\n  const n = Number.parseInt(raw, 10);\n  if (!Number.isFinite(n) || n <= 0) return null; // let caller omit --limit\n  return n;\n}\nconst args = ['list'];\nconst limit = normalizeLimit(process.env.ECC_ITEMS_LIMIT);\nif (limit) args.push('--limit', String(limit));","typeGuard":"function isPositiveInt(value) {\n  const n = Number.parseInt(value, 10);\n  return Number.isFinite(n) && n > 0 && String(n) === String(value).trim();\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","validation","work-items","numeric"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}