SonarSource/sonarqube · warning
Failed to fetch GitLab repository URL for ALM setting '{}' a
Error message
Failed to fetch GitLab repository URL for ALM setting '{}' and project ID '{}' What it means
This warning is logged by GetBindingAction.setGitlabRepositoryUrl when the GitLab REST client call to fetch the project (to read its web URL) fails for any reason other than a non-numeric project ID. The exception is swallowed so 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:175
}
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) {
LOG.warn("Invalid GitLab project ID '{}' for ALM setting '{}': must be a valid number",
projectAlmSetting.getAlmRepo(), almSetting.getKey(), e);
} catch (Exception e) {
LOG.warn("Failed to fetch GitLab repository URL for ALM setting '{}' and project ID '{}'",
almSetting.getKey(), projectAlmSetting.getAlmRepo(), e);
}
}
}
private static void setBitbucketCloudRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting, GetBindingWsResponse.Builder builder) {
String workspace = almSetting.getAppId();
String slug = projectAlmSetting.getAlmRepo();
if (isNotBlank(workspace) && isNotBlank(slug)) {
HttpUrl repositoryUrl = requireNonNull(HttpUrl.parse(BITBUCKET_CLOUD_ROOT_URL))
.newBuilder()
.addPathSegment(workspace)
.addPathSegment(slug)
.build();
builder.setRepositoryUrl(repositoryUrl.toString());
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Verify the personal access token in the GitLab ALM setting still exists and has read_api scope, then update it via api/alm_settings/update_gitlab
- Check the attached stack trace for the HTTP status: 401/403 means token/permissions, 404 means wrong project ID or deleted project
- Confirm SonarQube can reach the GitLab URL (curl the configured URL from the SonarQube host)
- Re-bind the project with a valid numeric project ID if the project was recreated in GitLab
Example fix
// before: expired PAT alm_settings/update_gitlab?key=gitlab1&personal_access_token=old_token // after alm_settings/update_gitlab?key=gitlab1&personal_access_token=glpat-NEW_VALID_TOKEN
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: verify token and project reachability before binding curl -H "PRIVATE-TOKEN: <pat>" "<gitlab-url>/api/v4/projects/<projectId>" # expect 200
Try / catch
// Callers of get_binding: treat missing repositoryUrl as transient and retry once
if (!response.hasRepositoryUrl()) {
try { response = retryWithBackoff(() -> service.getBinding(request), 2); }
catch (Exception e) { log.warn("GitLab binding lookup still failing", e); }
} Prevention
- Monitor GitLab PAT expiry dates and rotate before they lapse
- Grant the PAT read_api scope
- Alert on GitLab instance URL changes (renamed organizations)
- Check egress connectivity from the SonarQube host to GitLab after network changes
When it happens
Trigger: GET api/alm_settings/get_binding on a GitLab-bound project where the GitLab API call with the stored personal access token and project ID returns 401 (bad/expired PAT), 404 (project not found or no permission), 5xx, or the GitLab URL is unreachable.
Common situations: Expired or revoked GitLab personal access token lacking 'read_api' scope; project deleted or made private in GitLab; GitLab instance moved to a new URL; network/firewall changes blocking SonarQube's egress to GitLab.
Related errors
- Failed to fetch Azure repository URL for ALM setting '{}', p
- Skipping GitHub authentication setup: {}
- Failed to resolve url/repoId for DevOps Platform binding '{}
- Failed to validate configuration, check URL and Private Key
- Could not validate GitLab read permission. Got an unexpected
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/4952f8b3672367cd.
Report an issue: GitHub.