mastra-ai/mastra · error

Platform GitHub token minting requires between one and ten i

Error message

Platform GitHub token minting requires between one and ten installation repositories.

What it means

Thrown by PlatformGithubIntegration.mintInstallationToken when the installation exposes zero or more than ten repositories. GitHub installation tokens scoped with a 'repositories' list are limited to 10 repos per request, and an empty list would mint a meaningless or overly broad token, so the guard enforces 1-10 before minting.

Source

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

        owner: string;
        name: string;
        fullName: string;
        private: boolean;
        defaultBranch: string;
      }>;
    }>('GET', `${API_PREFIX}/github-app/installations/${installationId}/repositories`);
    const repos = result.repositories.map(repository => ({ ...repository, installationId }));
    setBounded(this.#installationReposCache, installationId, {
      repos,
      expiresAt: Date.now() + INSTALLATION_REPOS_CACHE_TTL_MS,
    });
    return repos;
  }

  async mintInstallationToken(installationId: number): Promise<string> {
    const repositories = await this.listInstallationRepos(installationId);
    if (repositories.length === 0 || repositories.length > 10) {
      throw new Error('Platform GitHub token minting requires between one and ten installation repositories.');
    }
    const result = await this.#client.request<{ token: string }>(
      'POST',
      `${API_PREFIX}/github-app/installations/${installationId}/token`,
      { repositories: repositories.map(repository => repository.name), permissions: REPOSITORY_TOKEN_PERMISSIONS },
    );
    return result.token;
  }

  async addIssueLabels(
    _installationId: number,
    sourceId: string,
    issueNumber: number,
    labels: string[],
  ): Promise<string[]> {
    const result = await this.#client.request<{ labels: string[] }>(
      'POST',
      repositoryPath(sourceId, `issues/${issueNumber}/labels`),

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Restrict the GitHub App installation to at most 10 repositories in GitHub settings (Repository access > Only select repositories)
  2. Split large installations into multiple installations of <=10 repos each and mint per-installation tokens
  3. Ensure at least one repository is selected for the installation before minting
  4. Use a different auth path (e.g. org-level token or unscoped token endpoint) if repo-scoping to <=10 is not feasible

Example fix

// before
const token = await github.mintInstallationToken(installationId); // 40 repos
// after
const repos = await github.listInstallationRepos(installationId);
const token = await github.mintInstallationTokenForRepos(installationId, repos.slice(0, 10).map(r => r.name));
Defensive patterns

Strategy: validation

Validate before calling

const repos = await github.listInstallationRepos(installationId);
if (repos.length === 0 || repos.length > 10) {
  throw new Error(`installation ${installationId} has ${repos.length} repos; token minting requires 1-10`);
}

Try / catch

try {
  const token = await github.mintInstallationToken(installationId);
} catch (err) {
  if (err instanceof Error && err.message.includes('between one and ten installation repositories')) {
    // fall back to per-repo scoping or split installations
  } else throw err;
}

Prevention

When it happens

Trigger: Calling mintInstallationToken(installationId) where listInstallationRepos returns [] (app installed on the org but no repos selected) or >10 repos (app installed on all repositories of a large org).

Common situations: GitHub App installed with 'All repositories' access on a big org; freshly installed app with no repository permissions granted yet; calling the token API directly for an installation id without narrowing repositories.

Related errors


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