SonarSource/sonarqube · warning

Failed to fetch Azure repository URL for ALM setting '{}', p

Error message

Failed to fetch Azure repository URL for ALM setting '{}', project '{}' and repository '{}'

What it means

This warning is logged by GetBindingAction.setAzureRepositoryUrl when the Azure DevOps REST call to fetch the repository web URL fails. The code uses almSetting's URL, a personal access token, the stored almSlug (project) and almRepo (repository); any exception is swallowed and the binding response is returned without a repositoryUrl.

Source

Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java:207

        .build();
      builder.setRepositoryUrl(repositoryUrl.toString());
    }
  }

  private void setAzureRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting, GetBindingWsResponse.Builder builder) {
    if (isNotBlank(projectAlmSetting.getAlmSlug()) && isNotBlank(projectAlmSetting.getAlmRepo()) && isNotBlank(almSetting.getUrl())) {
      try {
        String personalAccessToken = almSetting.getDecryptedPersonalAccessToken(encryption);
        if (isNotBlank(personalAccessToken)) {
          GsonAzureRepo azureRepo = azureDevOpsHttpClient.getRepo(
            requireNonNull(almSetting.getUrl()),
            personalAccessToken,
            requireNonNull(projectAlmSetting.getAlmSlug()),
            requireNonNull(projectAlmSetting.getAlmRepo()));
          builder.setRepositoryUrl(azureRepo.getWebUrl());
        }
      } catch (Exception e) {
        LOG.warn("Failed to fetch Azure repository URL for ALM setting '{}', project '{}' and repository '{}'",
          almSetting.getKey(), projectAlmSetting.getAlmSlug(), projectAlmSetting.getAlmRepo(), e);
      }
    }
  }

  private static void setBitbucketServerRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting,
    GetBindingWsResponse.Builder builder) {
    String serverUrl = almSetting.getUrl();
    String bitbucketProjectKey = projectAlmSetting.getAlmRepo();
    String repositorySlug = projectAlmSetting.getAlmSlug();
    if (isNotBlank(serverUrl) && isNotBlank(bitbucketProjectKey) && isNotBlank(repositorySlug)) {
      HttpUrl baseUrl = HttpUrl.parse(serverUrl);
      if (baseUrl == null) {
        LOG.warn("Failed to construct Bitbucket Server repository URL for ALM setting '{}': invalid server URL", almSetting.getKey());
        return;
      }
      builder.setRepositoryUrl(baseUrl.newBuilder()
        .addPathSegment("projects")

View on GitHub (pinned to 184c821202)

Solutions

  1. Refresh the Azure DevOps personal access token in the ALM setting (api/alm_settings/update_azure) ensuring Code Read scope
  2. Verify almSlug and almRepo exactly match the Azure DevOps project and repository names, then re-bind with api/alm_settings/set_binding if not
  3. Test the configured Azure URL and organization from the SonarQube host (check for renamed organization)
  4. Inspect the attached stack trace/inner message in the log for the specific HTTP status returned by Azure

Example fix

// before: renamed repo
alm_settings/set_binding?project=p&almSettingKey=azure1&almSlug=Proj&almRepo=old-repo
// after
alm_settings/set_binding?project=p&almSettingKey=azure1&almSlug=Proj&almRepo=renamed-repo
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: verify Azure PAT and repo before binding
curl -u ":<pat>" "https://dev.azure.com/<org>/<project>/_apis/git/repositories/<repo>?api-version=7.0" # expect 200

Try / catch

// Callers: degrade gracefully when repositoryUrl is absent
if (!response.hasRepositoryUrl()) {
  log.warn("Azure binding metadata unavailable; check PAT and repo slugs");
}

Prevention

When it happens

Trigger: GET api/alm_settings/get_binding on an Azure DevOps-bound project where the Azure API call fails: invalid/expired PAT, wrong organization URL, almSlug/almRepo not matching a real Azure project/repository, or network failure.

Common situations: Azure DevOps PAT expired (PATs have a max lifetime); repository renamed or deleted in Azure; project name changed; the Azure organization was renamed so the configured URL no longer resolves; typo in the project/repository slug.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/23595a99079b8184. Report an issue: GitHub.