{"record":{"id":"65540b45c9ea2cca","repo":"mastra-ai/mastra","slug":"github-cursor-must-be-a-positive-page-number-65540b","errorCode":null,"errorMessage":"GitHub cursor must be a positive page number.","messagePattern":"GitHub cursor must be a positive page number\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mastracode/factory/src/integrations/platform/github/integration.ts","lineNumber":1565,"sourceCode":"\nfunction requireSingleSource(sourceIds: string[], message: string): string {\n  if (sourceIds.length !== 1) throw new Error(message);\n  return sourceIds[0]!;\n}\n\nfunction requireSource(sourceId: string | undefined, message: string): string {\n  if (!sourceId) throw new Error(message);\n  return sourceId;\n}\n\nfunction normalizeLabels(labels: string[] | undefined): string[] {\n  return [...new Set((labels ?? []).map(label => label.trim()).filter(Boolean))];\n}\n\nfunction parsePositiveCursor(cursor: string | undefined): number {\n  if (cursor === undefined) return 1;\n  const parsed = parsePositiveInteger(cursor);\n  if (parsed === null) throw new Error('GitHub cursor must be a positive page number.');\n  return parsed;\n}\n\nfunction parsePositiveInteger(value: string): number | null {\n  if (!/^\\d+$/.test(value)) return null;\n  const parsed = Number(value);\n  return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;\n}\n\nfunction parseGithubExternalTarget(externalId: string): { repository: string; issueId: string } | null {\n  const match =\n    externalId.match(/^(.+\\/.+):(\\d+)$/) ??\n    externalId.match(/^github:(\\d+):(?:issue|pull-request):(\\d+)$/) ??\n    externalId.match(/^(\\d+):(\\d+)$/);\n  if (!match?.[1] || !match[2] || parsePositiveInteger(match[2]) === null) return null;\n  return { repository: match[1], issueId: match[2] };\n}\n","sourceCodeStart":1547,"sourceCodeEnd":1583,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/github/integration.ts#L1547-L1583","documentation":"Thrown by parsePositiveCursor when a pagination cursor is provided but is not a positive integer (fails parsePositiveInteger). GitHub list capabilities paginate by page number, so the cursor must be a positive integer string; absent cursor defaults to page 1.","triggerScenarios":"Passing cursor values like 'abc', '0', '-1', '1.5', or '' (non-undefined but invalid) into a paginated GitHub list capability.","commonSituations":"Echoing back a malformed nextCursor from a previous response; client-side cursor corruption; using an opaque cursor from a different integration's pagination scheme; passing 0 as the first page.","solutions":["Omit the cursor entirely (or pass undefined) to fetch page 1","Only pass through the exact nextCursor string returned by a previous call","Validate the cursor is /^[1-9]\\d*$/ before calling","Clear stale client-side pagination state and restart listing from page 1"],"exampleFix":"// before\nawait github.listIssues({ installationId, sourceId, cursor: '0' });\n// after\nawait github.listIssues({ installationId, sourceId }); // first page\n// or: cursor: previousResponse.nextCursor","handlingStrategy":"validation","validationCode":"function safeCursor(cursor?: string): number | undefined {\n  if (cursor === undefined) return undefined;\n  if (!/^[1-9]\\d*$/.test(cursor)) throw new Error(`invalid cursor: ${cursor}`);\n  return Number(cursor);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await github.listIssues({ installationId, sourceId, cursor });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('positive page number')) {\n    return await github.listIssues({ installationId, sourceId }); // restart at page 1\n  } else throw err;\n}","preventionTips":["Only pass through nextCursor values returned by the same integration","Never hand-craft cursors or reuse cursors across providers","Persist cursors opaquely and reset pagination state on decode failures","Treat page 1 (omitted cursor) as the fallback"],"tags":["github","pagination","validation","cursor"],"backgroundTag":"invalid-pagination-cursor","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}