{"record":{"id":"be2c01e5f0b84b26","repo":"mastra-ai/mastra","slug":"version-control-installation-not-found","errorCode":null,"errorMessage":"Version-control installation not found.","messagePattern":"Version-control installation not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/integration.ts","lineNumber":298,"sourceCode":"            orgId,\n            input: {\n              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),","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/integration.ts#L280-L316","documentation":"This error is thrown when resolving clone credentials for a repository whose stored installation record cannot be found. The repository row exists, but its installationId does not resolve to an installation in source-control storage, so the integration cannot mint a GitHub App installation token for cloning.","triggerScenarios":"Calling the integration's repository-credential resolution (the public member that returns cloneUrl plus a bearer authorization token) with a repositoryId whose repository.installationId points to a missing or deleted installation row, or an installation stored under a different orgId.","commonSituations":"A GitHub App installation was uninstalled and its record purged while the repository row remained; cross-org data where the repository was copied/imported into another org; partial data cleanup removing installations but not repositories.","solutions":["Re-install the GitHub App on the repository so a new installation record is created, then re-sync the repository row so installationId points at it","Delete or re-import the orphaned repository record so installationId matches an existing installation","Verify sourceControlStorage.installations contains a row with the orgId and id the repository references","Audit data cleanup jobs that remove installations without removing dependent repositories"],"exampleFix":"// before\nawait sourceControlStorage.repositories.create({ orgId, installationId: staleInstallationId, slug });\n// after\nconst inst = await sourceControlStorage.installations.get({ orgId, id: freshInstallationId });\nif (!inst) throw new Error('install the GitHub App first');\nawait sourceControlStorage.repositories.create({ orgId, installationId: freshInstallationId, slug });","handlingStrategy":"validation","validationCode":"const repo = await sourceControlStorage.repositories.get({ orgId, id: repositoryId });\nif (!repo) throw new Error('repository not found');\nconst installation = await sourceControlStorage.installations.get({ orgId, id: repo.installationId });\nif (!installation) throw new Error('installation missing for repository ' + repositoryId);","typeGuard":null,"tryCatchPattern":"try {\n  const creds = await gh.getCloneCredentials({ orgId, repositoryId });\n} catch (e) {\n  if (e.message === 'Version-control installation not found.') {\n    // prompt re-install of the GitHub App / re-sync repository\n  } else throw e;\n}","preventionTips":["Treat installation removal as a cascade that also deletes or flags dependent repositories","Periodically reconcile repositories whose installationId no longer resolves","Re-sync installations from GitHub webhooks (installation.deleted events)"],"tags":["github","storage","integration"],"backgroundTag":"orphaned-resource-reference","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}