{"record":{"id":"1f858ffbf474e26c","repo":"mastra-ai/mastra","slug":"platform-github-token-minting-requires-between-one","errorCode":null,"errorMessage":"Platform GitHub token minting requires between one and ten installation repositories.","messagePattern":"Platform GitHub token minting requires between one and ten installation repositories\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/github/integration.ts","lineNumber":1023,"sourceCode":"        owner: string;\n        name: string;\n        fullName: string;\n        private: boolean;\n        defaultBranch: string;\n      }>;\n    }>('GET', `${API_PREFIX}/github-app/installations/${installationId}/repositories`);\n    const repos = result.repositories.map(repository => ({ ...repository, installationId }));\n    setBounded(this.#installationReposCache, installationId, {\n      repos,\n      expiresAt: Date.now() + INSTALLATION_REPOS_CACHE_TTL_MS,\n    });\n    return repos;\n  }\n\n  async mintInstallationToken(installationId: number): Promise<string> {\n    const repositories = await this.listInstallationRepos(installationId);\n    if (repositories.length === 0 || repositories.length > 10) {\n      throw new Error('Platform GitHub token minting requires between one and ten installation repositories.');\n    }\n    const result = await this.#client.request<{ token: string }>(\n      'POST',\n      `${API_PREFIX}/github-app/installations/${installationId}/token`,\n      { repositories: repositories.map(repository => repository.name), permissions: REPOSITORY_TOKEN_PERMISSIONS },\n    );\n    return result.token;\n  }\n\n  async addIssueLabels(\n    _installationId: number,\n    sourceId: string,\n    issueNumber: number,\n    labels: string[],\n  ): Promise<string[]> {\n    const result = await this.#client.request<{ labels: string[] }>(\n      'POST',\n      repositoryPath(sourceId, `issues/${issueNumber}/labels`),","sourceCodeStart":1005,"sourceCodeEnd":1041,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/github/integration.ts#L1005-L1041","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Restrict the GitHub App installation to at most 10 repositories in GitHub settings (Repository access > Only select repositories)","Split large installations into multiple installations of <=10 repos each and mint per-installation tokens","Ensure at least one repository is selected for the installation before minting","Use a different auth path (e.g. org-level token or unscoped token endpoint) if repo-scoping to <=10 is not feasible"],"exampleFix":"// before\nconst token = await github.mintInstallationToken(installationId); // 40 repos\n// after\nconst repos = await github.listInstallationRepos(installationId);\nconst token = await github.mintInstallationTokenForRepos(installationId, repos.slice(0, 10).map(r => r.name));","handlingStrategy":"validation","validationCode":"const repos = await github.listInstallationRepos(installationId);\nif (repos.length === 0 || repos.length > 10) {\n  throw new Error(`installation ${installationId} has ${repos.length} repos; token minting requires 1-10`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const token = await github.mintInstallationToken(installationId);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('between one and ten installation repositories')) {\n    // fall back to per-repo scoping or split installations\n  } else throw err;\n}","preventionTips":["Configure the GitHub App installation with 'Only select repositories' capped at 10","Check repository count via listInstallationRepos before minting","Split large orgs into multiple app installations","Alert on installations whose repository count crosses 10"],"tags":["github","installation-token","limits","permissions"],"backgroundTag":"token-minting-limit-exceeded","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}