SonarSource/sonarqube · warning

Failed to construct GitHub repository URL for ALM setting '{

Error message

Failed to construct GitHub repository URL for ALM setting '{}' and repository '{}'

What it means

This warning is logged by GetBindingAction.setGithubRepositoryUrl when SonarQube cannot build the web URL of a GitHub repository while serving the ALM binding lookup request. It parses the configured GitHub base URL and appends the stored almRepo path segment; any failure (unparseable URL, null/blank repo) is swallowed and logged as a warning so the binding response is still returned without a repositoryUrl.

Source

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

      } else if (almSetting.getAlm() == ALM.BITBUCKET) {
        setBitbucketServerRepositoryUrl(almSetting, projectAlmSetting, builder);
      }

      return builder.build();
    }
  }

  private static void setGithubRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting, GetBindingWsResponse.Builder builder) {
    if (isNotBlank(projectAlmSetting.getAlmRepo()) && isNotBlank(almSetting.getUrl())) {
      try {
        String baseUrl = GithubApplicationClientImpl.convertApiUrlToBaseUrl(requireNonNull(almSetting.getUrl()));
        HttpUrl repositoryUrl = HttpUrl.parse(baseUrl)
          .newBuilder()
          .addPathSegments(requireNonNull(projectAlmSetting.getAlmRepo()))
          .build();
        builder.setRepositoryUrl(repositoryUrl.toString());
      } catch (Exception e) {
        LOG.warn("Failed to construct GitHub repository URL for ALM setting '{}' and repository '{}'",
          almSetting.getKey(), projectAlmSetting.getAlmRepo(), e);
      }
    }
  }

  private void setGitlabRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting, GetBindingWsResponse.Builder builder) {
    if (isNotBlank(projectAlmSetting.getAlmRepo()) && isNotBlank(almSetting.getUrl())) {
      try {
        String personalAccessToken = almSetting.getDecryptedPersonalAccessToken(encryption);
        if (isNotBlank(personalAccessToken)) {
          Long gitlabProjectId = Long.parseLong(requireNonNull(projectAlmSetting.getAlmRepo()));
          Project gitlabProject = gitlabApplicationClient.getProject(
            requireNonNull(almSetting.getUrl()),
            personalAccessToken,
            gitlabProjectId);
          builder.setRepositoryUrl(gitlabProject.getWebUrl());
        }
      } catch (NumberFormatException e) {

View on GitHub (pinned to 184c821202)

Solutions

  1. Fix the GitHub ALM setting URL in Administration > DevOps Platform Integrations so it is a fully qualified, parseable URL (e.g. https://github.mycompany.com/ or https://github.com/)
  2. Re-bind the project via api/alm_settings/set_binding or the project's ALM binding page so almRepo is populated with the correct 'org/repo' value
  3. Verify with GET api/alm_settings/get_binding (or list_alm_settings) that almRepo is non-null for the project
  4. Check the server log stack trace attached to this warning to identify which field failed (URL parse vs null repo)

Example fix

// before: almSetting url "github.company.com"
// after: update ALM setting with a valid absolute URL
curl -X POST -u admin:token 'https://sonar.example.com/api/alm_settings/update_github' -d 'key=github-app-id' -d 'url=https://github.company.com'
Defensive patterns

Strategy: validation

Validate before calling

// Validate before configuring the ALM setting / binding
String url = almSetting.getUrl();
if (url == null || OkHttp.parse(url) == null) throw new IllegalArgumentException("GitHub ALM setting URL must be an absolute http(s) URL");
if (projectAlmSetting.getAlmRepo() == null || projectAlmSetting.getAlmRepo().isBlank()) throw new IllegalArgumentException("almRepo (org/repo) is required");

Try / catch

// The server already swallows this; clients of get_binding should treat missing repositoryUrl as degraded data
GetBindingWsResponse r = service.getBinding(request);
if (!r.hasRepositoryUrl()) { /* re-bind or fix ALM setting */ }

Prevention

When it happens

Trigger: GET api/alm_settings/get_binding for a GitHub-bound project where almSetting.getUrl() is malformed or not parseable by OkHttp's HttpUrl.parse, or projectAlmSetting.getAlmRepo() is null (requireNonNull throws NPE) or contains characters that break URL building.

Common situations: A GitHub ALM setting whose URL was entered as 'github.mycompany.com' without an https:// scheme; a project binding persisted before the repo field was populated; an import/migration leaving almRepo null.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


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