{"record":{"id":"efdb5041b18a7418","repo":"SonarSource/sonarqube","slug":"cannot-mint-a-github-installation-token-unknown-p","errorCode":null,"errorMessage":"Cannot mint a GitHub installation token: unknown project '{}'","messagePattern":"Cannot mint a GitHub installation token: unknown project '(.+?)'","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":79,"sourceCode":"  private final GithubGlobalSettingsValidator githubGlobalSettingsValidator;\n  private final GithubApplicationClient githubApplicationClient;\n\n  public GithubInstallationTokenProviderImpl(DbClient dbClient, GithubGlobalSettingsValidator githubGlobalSettingsValidator,\n    GithubApplicationClientImpl githubApplicationClient) {\n    this.dbClient = dbClient;\n    this.githubGlobalSettingsValidator = githubGlobalSettingsValidator;\n    this.githubApplicationClient = githubApplicationClient;\n  }\n\n  @Override\n  public Optional<GithubInstallationToken> mint(String projectKey) {\n    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);","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/github/GithubInstallationTokenProviderImpl.java#L61-L97","documentation":"GithubInstallationTokenProviderImpl.mint logs this warning and returns Optional.empty() when selectProjectByKey cannot find a project for the supplied project key. Without a project, no GitHub App installation token can be minted. The Javadoc-described design returns empty at the first missing step rather than throwing, so callers see an empty Optional from mint().","triggerScenarios":"Requesting a GitHub installation token (api/alm_integrations/install_github_app path or internal mint call) with a projectKey that does not exist in the projects table.","commonSituations":"Stale project key in CI after the project was renamed/deleted; calling the wrong SonarQube instance; copy-paste of a key from a different organization or branch of environments (staging key used on production).","solutions":["Look up the correct project key via GET api/projects/search and fix it in the calling configuration.","Recreate the deleted project or re-import it from GitHub.","Point the caller at the correct SonarQube server/organization.","Pre-validate the key before minting so automation fails fast with a clear message."],"exampleFix":"// before\nPOST api/alm_integrations/install_github_app?projectKey=legacy-key -> empty\n// after\n# confirm key\nKEY=$(curl -s -u token: \"$SQ_URL/api/projects/search?q=service-api\" | jq -r '.components[0].key')\nPOST api/alm_integrations/install_github_app?projectKey=$KEY","handlingStrategy":"validation","validationCode":"# Verify the project exists before requesting a GitHub installation token\nKEY=$(curl -s -u \"$TOKEN:\" \"$SQ_URL/api/projects/search?q=$RAW_KEY\" | jq -r '.components[0].key // empty')\n[ -n \"$KEY\" ] || { echo \"unknown project\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hardcode project keys in CI; fetch them from provisioning output.","Confirm the SonarQube base URL matches the environment holding the project.","Handle empty mint results distinctly from HTTP errors in automation."],"tags":["github","project-not-found","alm-integration","installation-token"],"backgroundTag":"resource-not-found","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}