{"record":{"id":"b0443dc9bf93b3b4","repo":"mastra-ai/mastra","slug":"name-must-be-a-positive-integer","errorCode":null,"errorMessage":"${name} must be a positive integer.","messagePattern":"(.+?) must be a positive integer\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/github/integration.ts","lineNumber":1588,"sourceCode":"  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\nfunction optionalPositiveIntegerEnv(name: 'MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS'): number | undefined {\n  const value = process.env[name]?.trim();\n  if (!value) return undefined;\n  const parsed = parsePositiveInteger(value);\n  if (parsed === null) throw new Error(`${name} must be a positive integer.`);\n  return parsed;\n}\n\nfunction requirePositiveId(value: string, resource: string): number {\n  const parsed = parsePositiveInteger(value);\n  if (parsed === null) throw new Error(`GitHub ${resource} id must be a positive integer.`);\n  return parsed;\n}\n\nfunction reviewEvent(event: 'approve' | 'request-changes' | 'comment') {\n  if (event === 'approve') return 'APPROVE' as const;\n  if (event === 'request-changes') return 'REQUEST_CHANGES' as const;\n  return 'COMMENT' as const;\n}\n\nfunction isNotFound(error: unknown): boolean {\n  return error instanceof PlatformApiError && error.status === 404;\n}","sourceCodeStart":1570,"sourceCodeEnd":1606,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/github/integration.ts#L1570-L1606","documentation":"Thrown by optionalPositiveIntegerEnv when the MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS environment variable is set but does not parse as a positive integer. The library fails fast at configuration time so a typo'd interval (e.g. '5s', '0', '') never silently disables or breaks polling.","triggerScenarios":"Setting MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS to a non-integer value such as '1000ms', '0', '-500', '1e3', or a value with stray characters/whitespace-only content that still fails the digit check after trim.","commonSituations":"Including units in the value ('30000ms' instead of '30000'); using scientific notation; docker-compose YAML quoting numbers as strings with hidden characters; copy-pasting with thousands separators ('1,000').","solutions":["Set the variable to plain positive integer milliseconds, e.g. MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS=30000","Remove the variable entirely to use the built-in default interval","Check the runtime environment (docker env, .env file) for stray characters and strip units/separators","Restart the process after fixing so the integration constructor re-reads the env"],"exampleFix":"// before (in .env)\nMASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS=30s\n// after\nMASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS=30000","handlingStrategy":"validation","validationCode":"const raw = process.env.MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS;\nif (raw !== undefined && !/^\\d+$/.test(raw.trim())) {\n  throw new Error(`MASTRA_PLATFORM_GITHUB_POLLING_INTERVAL_MS must be integer milliseconds, got: ${raw}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const integration = new PlatformGithubIntegration({ pollingIntervalMsEnv: true /* reads env */ });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('must be a positive integer')) {\n    console.error(`Bad env config: ${err.message}; unset the var to use the default interval`);\n  } else throw err;\n}","preventionTips":["Document the variable as plain integer milliseconds (no units)","Validate env vars at deploy/lint time, not just runtime","Use dotenv with strict parsing to catch malformed values","Strip commas/units in your own config layer before the library reads it"],"tags":["configuration","env-var","github","validation"],"backgroundTag":"missing-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}