SonarSource/sonarqube · warning
Invalid GitLab project ID '{}' for ALM setting '{}': must be
Error message
Invalid GitLab project ID '{}' for ALM setting '{}': must be a valid number What it means
This warning is logged by GetBindingAction.setGitlabRepositoryUrl when the almRepo value stored on the project binding is not a numeric GitLab project ID. The code parses almRepo with Integer.parseInt/Long.parseLong before calling the GitLab API; a NumberFormatException triggers this specific warning instead of the generic fetch-failure one.
Source
Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java:172
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) {
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
- Re-bind the project with the numeric GitLab project ID (visible in GitLab under the project's general settings) via api/alm_settings/set_binding with almRepo=<numeric id>
- Check the stored value with GET api/alm_settings/list and confirm almRepo is a number for GitLab integrations
- If data was migrated, run a script to map project paths to GitLab API project IDs and update the bindings
- Confirm the ALM setting is of type GitLab; a GitHub/Bitbucket-style 'org/repo' value will never parse as a number
Example fix
// before alm_settings/set_binding?project=my_project&almRepo=group/my-repo // after alm_settings/set_binding?project=my_project&almRepo=42748211
Defensive patterns
Strategy: validation
Validate before calling
// Validate the GitLab project id before binding
String almRepo = projectAlmSetting.getAlmRepo();
if (almRepo == null || !almRepo.matches("\\d+")) {
throw new IllegalArgumentException("GitLab almRepo must be a numeric project ID, got: " + almRepo);
} Prevention
- Resolve project paths to numeric IDs via GET /api/v4/projects/<url-encoded-path> before binding
- Never copy almRepo formats between platforms (org/repo for GitHub, numeric ID for GitLab)
- Check almRepo value with api/alm_settings/list after any migration
- Document that set_binding for GitLab requires almRepo as a number
When it happens
Trigger: GET api/alm_settings/get_binding on a GitLab-bound project where projectAlmSetting.getAlmRepo() holds a project path like 'group/project' instead of a numeric ID, or is blank/whitespace.
Common situations: Bindings created by tooling that wrote the GitLab project path rather than the numeric project id; manual DB edits; older SonarQube versions or import scripts that stored the path; binding data copied from a different DevOps platform integration.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Missing Client Secret
- Could not parse pagination number
- Your Gitlab global configuration is incomplete. The GitLab U
- Your Gitlab global configuration is incomplete. The GitLab a
- GitLab project identifier must be a number, was '%s'
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/d0a3a0f408426644.
Report an issue: GitHub.