mastra-ai/mastra · error
Project repository not found for this integration.
Error message
Project repository not found for this integration.
What it means
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.
Source
Thrown at mastracode/factory/src/storage/domains/source-control/base.ts:614
const getProjectRepository = async (args: { orgId: string; id: string }): Promise<ProjectRepository | null> => {
const row = await db().findOne<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { id: args.id });
if (!row || !(await getConnection({ orgId: args.orgId, id: row.connection_id }))) return null;
return toProjectRepository(row);
};
const getProjectRepositoryById = async (id: string): Promise<ProjectRepository | null> => {
const row = await db().findOne<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { id });
if (!row) return null;
const connection = await db().findOne<ConnectionDbRow>(CONNECTIONS, {
id: row.connection_id,
integration_id: integrationId,
});
return connection ? toProjectRepository(row) : null;
};
const requireProjectRepositoryById = async (id: string): Promise<ProjectRepository> => {
const projectRepository = await getProjectRepositoryById(id);
if (!projectRepository) throw new Error('Project repository not found for this integration.');
return projectRepository;
};
return {
integrationId,
installations: {
list: async ({ orgId }) =>
(
await db().findMany<InstallationDbRow>(INSTALLATIONS, {
integration_id: integrationId,
org_id: orgId,
})
).map(toInstallation),
get: getInstallation,
findByExternalId: async ({ orgId, externalId }) => {
const row = await db().findOne<InstallationDbRow>(INSTALLATIONS, {
integration_id: integrationId,
org_id: orgId,View on GitHub (pinned to 75dd419e61)
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
Example fix
// before
const pr = await forIntegration.projectRepositories.requireById(id);
// after
const link = await forIntegration.projectRepositories.getById(id);
if (!link) {
const created = await forIntegration.projectRepositories.link({ orgId, connectionId, repositoryId });
} Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await getProjectRepositoryById(id);
if (!existing) throw new Error(`Project repository ${id} not linked`); Type guard
function isProjectRepository(v: unknown): v is ProjectRepository {
return !!v && typeof v === 'object' && 'connectionId' in v && 'repositoryId' in v;
} Try / catch
try {
pr = await requireProjectRepositoryById(id);
} catch (e) {
if (e instanceof Error && e.message.includes('Project repository not found')) {
pr = await link({ orgId, connectionId, repositoryId });
} else throw e;
} Prevention
- Persist link ids returned by link() rather than hardcoding
- Re-link after deleting connections or repositories
- Scope ids per integration instance
When it happens
Trigger: Calling requireProjectRepositoryById (via forIntegration projectRepositories accessors) with an id that was never linked, was deleted, or belongs to another integration.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Source-control installation not found for this organization
- Source-control repository not found for this organization an
- Repository ${id} not found in organization ${orgId}
- Factory project not found for this organization.
- Source-control installation not found
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/f6dc809a71f2836e.
Report an issue: GitHub.