{"record":{"id":"7b3eca23d03db03c","repo":"mastra-ai/mastra","slug":"github-installation-id-is-invalid","errorCode":null,"errorMessage":"GitHub installation id is invalid.","messagePattern":"GitHub installation id is invalid\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/integration.ts","lineNumber":300,"sourceCode":"              installationId,\n              externalId: repository.externalId,\n              slug: repository.slug,\n              defaultBranch: repository.defaultBranch,\n              providerMetadata: repository.metadata,\n            },\n          }),\n        ),\n      ),\n    getRepositoryAccess: async ({ orgId, repositoryId }) => {\n      const repository = await this.sourceControlStorage.repositories.get({ orgId, id: repositoryId });\n      if (!repository) throw new Error('Version-control repository not found.');\n      const installation = await this.sourceControlStorage.installations.get({\n        orgId,\n        id: repository.installationId,\n      });\n      if (!installation) throw new Error('Version-control installation not found.');\n      const installationId = Number.parseInt(installation.externalId, 10);\n      if (!Number.isSafeInteger(installationId)) throw new Error('GitHub installation id is invalid.');\n      return {\n        cloneUrl: `https://github.com/${repository.slug}.git`,\n        authorization: { scheme: 'bearer', token: await this.mintInstallationToken(installationId) },\n      };\n    },\n    listPullRequests: input => this.#listPullRequests(input),\n    getPullRequest: input => this.#getPullRequest(input),\n    createPullRequest: input => this.#createPullRequest(input),\n    updatePullRequest: input => this.#updatePullRequest(input),\n    closePullRequest: input => this.#closePullRequest(input),\n    mergePullRequest: input => this.#mergePullRequest(input),\n    listComments: input => this.#listComments(input),\n    createComment: input => this.#createComment(input),\n    updateComment: input => this.#updateComment(input),\n    deleteComment: input => this.#deleteComment(input),\n    listReviews: input => this.#listReviews(input),\n    getReview: input => this.#getReview(input),\n    createReview: input => this.#createReview(input),","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/integration.ts#L282-L318","documentation":"Thrown when the stored installation's externalId cannot be parsed into a safe integer. The integration parses externalId with Number.parseInt and requires Number.isSafeInteger before minting an installation token, so a malformed or non-numeric external id aborts credential resolution.","triggerScenarios":"Resolving clone credentials for a repository whose installation record has an externalId that is empty, non-numeric (e.g. a UUID or slug), or exceeds Number.MAX_SAFE_INTEGER.","commonSituations":"A different integration/adapter stored its own identifier format in externalId; a migration wrote the GitHub installation id as a string with whitespace or a non-numeric placeholder; extremely large ids stored with formatting.","solutions":["Fix the installation record so externalId holds the numeric GitHub App installation id as a decimal string","Re-sync the installation from GitHub so externalId is populated correctly","Validate externalId with Number.isSafeInteger(Number.parseInt(externalId, 10)) at write time to reject bad values early"],"exampleFix":"// before\nawait installations.upsert({ orgId, externalId: 'ghapp-abc123' });\n// after\nawait installations.upsert({ orgId, externalId: '51982311' }); // numeric GitHub installation id","handlingStrategy":"validation","validationCode":"if (!/^[0-9]+$/.test(installation.externalId ?? '') || !Number.isSafeInteger(Number(installation.externalId))) {\n  throw new Error('installation externalId must be a numeric GitHub installation id');\n}","typeGuard":"function hasNumericInstallationId(inst: { externalId: string | null }): boolean {\n  const n = Number.parseInt(inst.externalId ?? '', 10);\n  return Number.isSafeInteger(n);\n}","tryCatchPattern":"try {\n  const creds = await gh.getCloneCredentials({ orgId, repositoryId });\n} catch (e) {\n  if (e.message === 'GitHub installation id is invalid.') {\n    // re-sync the installation record from GitHub\n  } else throw e;\n}","preventionTips":["Validate externalId format at upsert time, rejecting non-numeric values","Store GitHub installation ids as strings of digits exactly as returned by the API","Add a data-integrity check that parses all stored externalIds on migration"],"tags":["github","data-integrity","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}