{"record":{"id":"5641d9bd518048b6","repo":"SonarSource/sonarqube","slug":"cannot-mint-a-github-installation-token-project-5641d9","errorCode":null,"errorMessage":"Cannot mint a GitHub installation token: project '{}' is not bound to a GitHub App","messagePattern":"Cannot mint a GitHub installation token: project '(.+?)' is not bound to a GitHub App","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/github/GithubInstallationTokenProviderImpl.java","lineNumber":91,"sourceCode":"    String safeProjectKey = sanitizeForLog(projectKey);\n    AlmSettingDto resolvedAlmSetting;\n    String resolvedAlmRepo;\n    try (DbSession dbSession = dbClient.openSession(false)) {\n      Optional<ProjectDto> project = dbClient.projectDao().selectProjectByKey(dbSession, projectKey);\n      if (project.isEmpty()) {\n        LOG.warn(\"Cannot mint a GitHub installation token: unknown project '{}'\", safeProjectKey);\n        return Optional.empty();\n      }\n\n      Optional<ProjectAlmSettingDto> projectAlmSetting = dbClient.projectAlmSettingDao().selectByProject(dbSession, project.get());\n      if (projectAlmSetting.isEmpty()) {\n        LOG.warn(\"Cannot mint a GitHub installation token: project '{}' is not bound to any DevOps Platform\", safeProjectKey);\n        return Optional.empty();\n      }\n\n      Optional<AlmSettingDto> almSetting = dbClient.almSettingDao().selectByUuid(dbSession, projectAlmSetting.get().getAlmSettingUuid());\n      if (almSetting.isEmpty() || almSetting.get().getAlm() != ALM.GITHUB) {\n        LOG.warn(\"Cannot mint a GitHub installation token: project '{}' is not bound to a GitHub App\", safeProjectKey);\n        return Optional.empty();\n      }\n\n      String almRepo = projectAlmSetting.get().getAlmRepo();\n      if (almRepo == null || almRepo.isBlank()) {\n        LOG.warn(\"Cannot mint a GitHub installation token: project '{}' has no repository configured on its DevOps Platform binding\", safeProjectKey);\n        return Optional.empty();\n      }\n\n      resolvedAlmSetting = almSetting.get();\n      resolvedAlmRepo = almRepo;\n    }\n\n    // GitHub App calls below are network I/O, deliberately made outside the DbSession above: the\n    // orchestrator mints a fresh token before every git operation (no caching, by design), so\n    // holding a pooled DB connection for their duration would add unnecessary contention under load.\n    return mint(projectKey, resolvedAlmSetting, resolvedAlmRepo);\n  }","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/github/GithubInstallationTokenProviderImpl.java#L73-L109","documentation":"GithubInstallationTokenProviderImpl.mint logs this warning and returns Optional.empty() when the project's DevOps Platform binding is not a GitHub App binding — either the ALM setting was deleted (empty Optional from almSettingDao.selectByUuid) or its alm type is not ALM.GITHUB. Minting a GitHub App installation token only works for projects bound via a GitHub App configuration; GitLab/Bitbucket/Azure bindings cannot yield one.","triggerScenarios":"Minting a GitHub installation token for a project whose projectAlmSetting points to an almSettingUuid of a non-GitHub ALM (e.g. GitLab) or to a deleted ALM configuration.","commonSituations":"Organization migrated the project from GitLab/Azure to GitHub but left the old binding; global GitHub ALM setting deleted while project bindings remained; admin picked the wrong ALM configuration when binding the project.","solutions":["Re-bind the project to a GitHub App ALM configuration: POST api/alm_settings/set_github with the correct almSetting key.","Recreate the missing GitHub ALM configuration at global level (api/alm_integrations/create_github) if it was deleted.","Remove the stale non-GitHub binding first (api/alm_settings/remove_binding) if it conflicts, then bind to GitHub.","In tooling, check GET api/alm_settings/get_binding and confirm alm is 'github' before requesting installation tokens."],"exampleFix":"// before: binding almSetting points to GitLab config 'gitlab-company'\n// after\ncurl -u token: -X POST \"$SQ_URL/api/alm_settings/set_github\" \\\n  -d \"project=my-app\" -d \"almSetting=github-company\" -d \"repositoryName=org/my-app\"","handlingStrategy":"validation","validationCode":"# Confirm the binding is a GitHub App binding before minting\nALM=$(curl -s -u \"$TOKEN:\" \"$SQ_URL/api/alm_settings/get_binding?project=$KEY\" | jq -r '.alm // empty')\n[ \"$ALM\" = \"github\" ] || { echo \"Project bound to $ALM, not GitHub App\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-bind projects to GitHub when migrating off other ALMs; remove stale bindings.","Do not delete global GitHub ALM configurations while project bindings reference them.","Validate alm type in automation before requesting GitHub-specific tokens."],"tags":["github","wrong-binding","alm-integration","github-app"],"backgroundTag":"invalid-enum-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}