{"record":{"id":"311e3afc0365fb08","repo":"SonarSource/sonarqube","slug":"failed-to-count-bitbucket-cloud-repos-for-alm-sett","errorCode":null,"errorMessage":"Failed to count bitbucket_cloud repos for ALM setting '{}'","messagePattern":"Failed to count bitbucket_cloud repos for ALM setting '(.+?)'","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/onboarding/alm/OnboardingAlmConfiguration.java","lineNumber":316,"sourceCode":"      try {\n        AlmSettingDto almSettingDto;\n        try (DbSession dbSession = dbClient.openSession(false)) {\n          almSettingDto = dbClient.almSettingDao().selectByKey(dbSession, setting.key()).orElse(null);\n        }\n        if (almSettingDto == null) {\n          return OptionalLong.empty();\n        }\n        String clientId = almSettingDto.getClientId();\n        String clientSecret = decryptor.decrypt(almSettingDto.getClientSecret());\n        if (clientId == null || clientSecret == null) {\n          return OptionalLong.empty();\n        }\n        String accessToken = client.createAccessToken(clientId, clientSecret);\n        var repoList = client.searchReposWithAccessToken(accessToken, workspace, null, 1, 1);\n        Integer size = repoList != null ? repoList.getSize() : null;\n        return size != null ? OptionalLong.of(size) : OptionalLong.empty();\n      } catch (Exception e) {\n        LOG.warn(\"Failed to count bitbucket_cloud repos for ALM setting '{}'\", setting.key(), e);\n        return OptionalLong.empty();\n      }\n    }\n  }\n}\n","sourceCodeStart":298,"sourceCodeEnd":322,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/onboarding/alm/OnboardingAlmConfiguration.java#L298-L322","documentation":"BitbucketCloud repo counting calls createAccessToken with clientId/clientSecret then searchReposWithAccessToken to fetch a 1-item page and read its size. Any exception (OAuth failure, workspace error, HTTP error) is logged as this warning with the setting key and yields an empty count.","triggerScenarios":"fetchTotalCount for a bitbucket_cloud provider throws during token creation or repo search for the given ALM setting key; also when repoList or its size is null.","commonSituations":"Invalid/rotated Bitbucket Cloud OAuth client credentials; workspace renamed or access removed; Bitbucket API outages or rate limits; egress blocked to api.bitbucket.org.","solutions":["Verify the OAuth client id/secret on the bitbucket_cloud ALM setting and re-authorize","Check the attached exception for the Bitbucket API error (401/403/404/429)","Confirm the workspace name still exists and the OAuth consumer can access it","Test network connectivity to api.bitbucket.org from the SonarQube host"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if (clientId == null || clientSecret == null || workspace == null || workspace.isBlank()) return OptionalLong.empty();","typeGuard":"Integer size = repoList != null ? repoList.getSize() : null;\nif (size == null) return OptionalLong.empty();","tryCatchPattern":"try { ... } catch (Exception e) { LOG.warn(\"Failed to count bitbucket_cloud repos for ALM setting '{}'\", key, e); return OptionalLong.empty(); }","preventionTips":["Keep Bitbucket OAuth client credentials current","Confirm workspace name and consumer access after workspace changes","Add backoff for Bitbucket rate limits"],"tags":["bitbucket","bitbucket-cloud","alm","oauth"],"backgroundTag":"oauth-token-exchange-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}