{"record":{"id":"ca56cde175d79a20","repo":"affaan-m/ECC","slug":"invalid-issue-number-value","errorCode":null,"errorMessage":"Invalid issue number: ${value}","messagePattern":"Invalid issue number: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/github-coordination/gh-api.js","lineNumber":17,"sourceCode":"'use strict';\n\nconst { spawnSync } = require('child_process');\n\nfunction normalizeRepo(repo) {\n  const parts = String(repo || '').split('/').filter(Boolean);\n  if (parts.length !== 2) {\n    throw new Error(`Invalid repo format: \"${repo}\". Expected \"owner/repo\".`);\n  }\n  const [owner, name] = parts;\n  return { owner, name };\n}\n\nfunction normalizeIssueNumber(value) {\n  const parsed = Number.parseInt(String(value), 10);\n  if (!Number.isFinite(parsed) || parsed <= 0) {\n    throw new Error(`Invalid issue number: ${value}`);\n  }\n  return parsed;\n}\n\nfunction normalizeLabelValue(label) {\n  if (typeof label === 'string') {\n    return label.trim();\n  }\n  if (label && typeof label === 'object') {\n    return String(label.name || label.label || '').trim();\n  }\n  return '';\n}\n\nfunction normalizeLabels(labels) {\n  return Array.from(new Set((Array.isArray(labels) ? labels : []).map(normalizeLabelValue).filter(Boolean))).sort();\n}\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/github-coordination/gh-api.js#L1-L35","documentation":"Thrown by normalizeIssueNumber in gh-api.js when the value cannot be parsed via parseInt into a finite positive number. This is the gh-api-layer guard (companion to actions.js assertValidIssueNumber) and is slightly looser: it does not require an integer (parseInt already truncates), only > 0 and finite. It protects every gh issue view/list call from garbage input.","triggerScenarios":"Passing 'abc', '', '#', null, 0, -1, or NaN as the issue number; a value that parseInt cannot turn into a positive integer.","commonSituations":"CLI/web param not converted to a number; issue ref includes text parseInt can't handle; default sentinel 0 or -1 leaked through; empty string from a missing field.","solutions":["Pass a positive integer (or its string form like '42').","Strip non-digits and '#' before parsing: const n = Number.parseInt(String(raw).replace(/[^0-9]/g, ''), 10).","Validate at the input boundary: if (!(Number.isFinite(n) && n > 0)) throw.","Coordinate with assertValidIssueNumber upstream so malformed numbers are caught earlier with a clearer message."],"exampleFix":"// before\ngetIssue(repo, rawIssue);\n\n// after — normalize defensively\nconst issueNumber = Number.parseInt(String(rawIssue).replace(/[^0-9]/g, ''), 10);\nif (!Number.isFinite(issueNumber) || issueNumber <= 0) {\n  throw new Error(`Invalid issue number: ${rawIssue}`);\n}\ngetIssue(repo, issueNumber);","handlingStrategy":"validation","validationCode":"const n = Number.parseInt(String(value).replace(/[^0-9]/g, ''), 10);\nif (!Number.isFinite(n) || n <= 0) {\n  throw new Error(`issue number must be positive, got ${value}`);\n}","typeGuard":"function isPositiveIssueNumber(value) {\n  const n = Number.parseInt(String(value), 10);\n  return Number.isFinite(n) && n > 0;\n}","tryCatchPattern":"try {\n  getIssue(repo, issueNumber);\n} catch (e) {\n  if (/Invalid issue number/.test(e.message)) { console.error('Pass a positive integer issue number'); process.exit(2); }\n  throw e;\n}","preventionTips":["Strip non-digits before parsing issue references.","Validate at the input boundary, not at the gh-api layer.","Coordinate with assertValidIssueNumber upstream."],"tags":["github-coordination","gh-api","validation","numeric"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}