mastra-ai/mastra · error

Version-control installation not found.

Error message

Version-control installation not found.

What it means

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.

Source

Thrown at mastracode/factory/src/integrations/github/integration.ts:298

            orgId,
            input: {
              installationId,
              externalId: repository.externalId,
              slug: repository.slug,
              defaultBranch: repository.defaultBranch,
              providerMetadata: repository.metadata,
            },
          }),
        ),
      ),
    getRepositoryAccess: async ({ orgId, repositoryId }) => {
      const repository = await this.sourceControlStorage.repositories.get({ orgId, id: repositoryId });
      if (!repository) throw new Error('Version-control repository not found.');
      const installation = await this.sourceControlStorage.installations.get({
        orgId,
        id: repository.installationId,
      });
      if (!installation) throw new Error('Version-control installation not found.');
      const installationId = Number.parseInt(installation.externalId, 10);
      if (!Number.isSafeInteger(installationId)) throw new Error('GitHub installation id is invalid.');
      return {
        cloneUrl: `https://github.com/${repository.slug}.git`,
        authorization: { scheme: 'bearer', token: await this.mintInstallationToken(installationId) },
      };
    },
    listPullRequests: input => this.#listPullRequests(input),
    getPullRequest: input => this.#getPullRequest(input),
    createPullRequest: input => this.#createPullRequest(input),
    updatePullRequest: input => this.#updatePullRequest(input),
    closePullRequest: input => this.#closePullRequest(input),
    mergePullRequest: input => this.#mergePullRequest(input),
    listComments: input => this.#listComments(input),
    createComment: input => this.#createComment(input),
    updateComment: input => this.#updateComment(input),
    deleteComment: input => this.#deleteComment(input),
    listReviews: input => this.#listReviews(input),

View on GitHub (pinned to 75dd419e61)

Solutions

  1. 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
  2. Delete or re-import the orphaned repository record so installationId matches an existing installation
  3. Verify sourceControlStorage.installations contains a row with the orgId and id the repository references
  4. Audit data cleanup jobs that remove installations without removing dependent repositories

Example fix

// before
await sourceControlStorage.repositories.create({ orgId, installationId: staleInstallationId, slug });
// after
const inst = await sourceControlStorage.installations.get({ orgId, id: freshInstallationId });
if (!inst) throw new Error('install the GitHub App first');
await sourceControlStorage.repositories.create({ orgId, installationId: freshInstallationId, slug });
Defensive patterns

Strategy: validation

Validate before calling

const repo = await sourceControlStorage.repositories.get({ orgId, id: repositoryId });
if (!repo) throw new Error('repository not found');
const installation = await sourceControlStorage.installations.get({ orgId, id: repo.installationId });
if (!installation) throw new Error('installation missing for repository ' + repositoryId);

Try / catch

try {
  const creds = await gh.getCloneCredentials({ orgId, repositoryId });
} catch (e) {
  if (e.message === 'Version-control installation not found.') {
    // prompt re-install of the GitHub App / re-sync repository
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/be2c01e5f0b84b26. Report an issue: GitHub.