{"record":{"id":"f6dc809a71f2836e","repo":"mastra-ai/mastra","slug":"project-repository-not-found-for-this-integration","errorCode":null,"errorMessage":"Project repository not found for this integration.","messagePattern":"Project repository not found for this integration\\.","errorType":"exception","errorClass":null,"httpStatus":404,"severity":"error","filePath":"mastracode/factory/src/storage/domains/source-control/base.ts","lineNumber":614,"sourceCode":"    const getProjectRepository = async (args: { orgId: string; id: string }): Promise<ProjectRepository | null> => {\n      const row = await db().findOne<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { id: args.id });\n      if (!row || !(await getConnection({ orgId: args.orgId, id: row.connection_id }))) return null;\n      return toProjectRepository(row);\n    };\n\n    const getProjectRepositoryById = async (id: string): Promise<ProjectRepository | null> => {\n      const row = await db().findOne<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { id });\n      if (!row) return null;\n      const connection = await db().findOne<ConnectionDbRow>(CONNECTIONS, {\n        id: row.connection_id,\n        integration_id: integrationId,\n      });\n      return connection ? toProjectRepository(row) : null;\n    };\n\n    const requireProjectRepositoryById = async (id: string): Promise<ProjectRepository> => {\n      const projectRepository = await getProjectRepositoryById(id);\n      if (!projectRepository) throw new Error('Project repository not found for this integration.');\n      return projectRepository;\n    };\n\n    return {\n      integrationId,\n      installations: {\n        list: async ({ orgId }) =>\n          (\n            await db().findMany<InstallationDbRow>(INSTALLATIONS, {\n              integration_id: integrationId,\n              org_id: orgId,\n            })\n          ).map(toInstallation),\n        get: getInstallation,\n        findByExternalId: async ({ orgId, externalId }) => {\n          const row = await db().findOne<InstallationDbRow>(INSTALLATIONS, {\n            integration_id: integrationId,\n            org_id: orgId,","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/storage/domains/source-control/base.ts#L596-L632","documentation":"Thrown by requireProjectRepositoryById when no project-repository row exists with the given id for this integration. A project repository is the link between a project connection and a source-control repository; without a row, the factory cannot return a ProjectRepository.","triggerScenarios":"Calling requireProjectRepositoryById (via forIntegration projectRepositories accessors) with an id that was never linked, was deleted, or belongs to another integration.","commonSituations":"Using an id from a different integration instance; referencing a link that was removed by unlink/delete; hard-coded IDs from tests or another environment.","solutions":["Confirm the project repository id exists for this integration (list/get first)","Re-link the repository to the connection via projectRepositories.link","Check you are using the correct integration's storage instance"],"exampleFix":"// before\nconst pr = await forIntegration.projectRepositories.requireById(id);\n// after\nconst link = await forIntegration.projectRepositories.getById(id);\nif (!link) {\n  const created = await forIntegration.projectRepositories.link({ orgId, connectionId, repositoryId });\n}","handlingStrategy":"try-catch","validationCode":"const existing = await getProjectRepositoryById(id);\nif (!existing) throw new Error(`Project repository ${id} not linked`);","typeGuard":"function isProjectRepository(v: unknown): v is ProjectRepository {\n  return !!v && typeof v === 'object' && 'connectionId' in v && 'repositoryId' in v;\n}","tryCatchPattern":"try {\n  pr = await requireProjectRepositoryById(id);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Project repository not found')) {\n    pr = await link({ orgId, connectionId, repositoryId });\n  } else throw e;\n}","preventionTips":["Persist link ids returned by link() rather than hardcoding","Re-link after deleting connections or repositories","Scope ids per integration instance"],"tags":["source-control","not-found","project-repository"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}