{"record":{"id":"255f869ac38ff486","repo":"mastra-ai/mastra","slug":"version-control-repository-not-found-255f86","errorCode":null,"errorMessage":"Version-control repository not found.","messagePattern":"Version-control repository not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/github/integration.ts","lineNumber":392,"sourceCode":"              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      // Every session materialization requests access; reuse a recent grant\n      // instead of re-minting through the Platform each time. The TTL keeps\n      // a wide margin under GitHub's ~60min installation-token lifetime.\n      const cacheKey = `${orgId}:${repositoryId}`;\n      const cached = this.#repositoryAccessCache.get(cacheKey);\n      if (cached && cached.expiresAt > Date.now()) return cached.access;\n      this.#repositoryAccessCache.delete(cacheKey);\n\n      const repository = await this.storage.repositories.get({ orgId, id: repositoryId });\n      if (!repository) throw new Error('Version-control repository not found.');\n      const cloneUrl = `https://github.com/${repository.slug}.git`;\n      const installation = await this.storage.installations.get({ orgId, id: repository.installationId });\n      if (!installation) throw new Error('Version-control installation not found.');\n      const installationId = parsePositiveInteger(installation.externalId);\n      if (installationId === null) throw new Error('GitHub installation id is invalid.');\n      const repositoryName = splitRepository(repository.slug).repo;\n\n      try {\n        const token = await this.#client.request<{ token: string }>(\n          'POST',\n          `${API_PREFIX}/github-app/installations/${installationId}/token`,\n          { repositories: [repositoryName], permissions: REPOSITORY_TOKEN_PERMISSIONS },\n        );\n        const access: RepositoryAccess = {\n          cloneUrl,\n          authorization: { scheme: 'bearer', token: token.token },\n        };\n        setBounded(this.#repositoryAccessCache, cacheKey, {","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/github/integration.ts#L374-L410","documentation":"Thrown by PlatformGithubIntegration (integration.ts:392) during repository access resolution when storage.repositories.get({orgId, repositoryId}) returns no record for the given org/repository pair. The integration needs the stored repository row (slug, installationId) to build the clone URL and locate the GitHub App installation, so a missing row is unrecoverable for that request.","triggerScenarios":"Requesting repository-scoped operations with a repositoryId that was never registered, belongs to a different orgId, or whose row was deleted from storage; stale references held after a repository was removed from the platform; cache misses force re-reads, exposing deletions that cached entries previously hid.","commonSituations":"Replaying an old webhook/event referencing a since-deleted repository; tenant/org mixups where the repository exists under another orgId; database resets or migrations dropping repository rows; typos or stale IDs in configuration calling the integration directly.","solutions":["Verify the repositoryId exists in storage for that orgId (storage.repositories.get({orgId, id})) before invoking the integration.","Check that the orgId matches the org the repository was registered under — cross-org IDs always miss.","Re-register/sync the repository (re-run the installation sync) if the row was deleted or the storage was reset.","Purge stale references: drop events/webhooks for deleted repositories instead of retrying them.","Catch this error and skip/mark the repository as unavailable rather than crashing a batch reconciliation."],"exampleFix":"// before\nconst access = await integration.resolveRepositoryAccess({ orgId, repositoryId }); // throws if deleted\n\n// after\nconst repo = await storage.repositories.get({ orgId, id: repositoryId });\nif (!repo) {\n  logger.warn('Repository no longer exists; skipping', { orgId, repositoryId });\n  return null;\n}\nconst access = await integration.resolveRepositoryAccess({ orgId, repositoryId });","handlingStrategy":"try-catch","validationCode":"// Pre-check the repository exists before requesting access through the integration\nconst repo = await storage.repositories.get({ orgId, id: repositoryId });\nif (!repo) {\n  throw new skipSignal(`Repository ${repositoryId} not found for org ${orgId}; skipping`);\n}","typeGuard":"function isRepositoryRecord(v: unknown): v is { id: string; slug: string; installationId: string } {\n  return (\n    typeof v === 'object' && v !== null &&\n    'id' in v && 'slug' in v && 'installationId' in v &&\n    typeof (v as any).slug === 'string'\n  );\n}","tryCatchPattern":"try {\n  const access = await integration.resolveRepositoryAccess({ orgId, repositoryId });\n} catch (err) {\n  if (err instanceof Error && err.message === 'Version-control repository not found.') {\n    logger.warn('Repository deleted or wrong org; skipping', { orgId, repositoryId });\n    return null; // do not retry: the row will not reappear on its own\n  }\n  throw err;\n}","preventionTips":["Resolve repository IDs from current storage, not cached webhook payloads from deleted repos.","Confirm orgId scoping when operating multi-tenant — always pair orgId + repositoryId from the same source record.","After storage resets/migrations, re-sync installations before running repository operations.","Mark missing repositories permanently skipped instead of retrying in loops."],"tags":["github","storage","not-found","repository"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}