{"record":{"id":"d0a3a0f408426644","repo":"SonarSource/sonarqube","slug":"invalid-gitlab-project-id-for-alm-setting","errorCode":null,"errorMessage":"Invalid GitLab project ID '{}' for ALM setting '{}': must be a valid number","messagePattern":"Invalid GitLab project ID '(.+?)' for ALM setting '(.+?)': must be a valid number","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java","lineNumber":172,"sourceCode":"          almSetting.getKey(), projectAlmSetting.getAlmRepo(), e);\n      }\n    }\n  }\n\n  private void setGitlabRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting, GetBindingWsResponse.Builder builder) {\n    if (isNotBlank(projectAlmSetting.getAlmRepo()) && isNotBlank(almSetting.getUrl())) {\n      try {\n        String personalAccessToken = almSetting.getDecryptedPersonalAccessToken(encryption);\n        if (isNotBlank(personalAccessToken)) {\n          Long gitlabProjectId = Long.parseLong(requireNonNull(projectAlmSetting.getAlmRepo()));\n          Project gitlabProject = gitlabApplicationClient.getProject(\n            requireNonNull(almSetting.getUrl()),\n            personalAccessToken,\n            gitlabProjectId);\n          builder.setRepositoryUrl(gitlabProject.getWebUrl());\n        }\n      } catch (NumberFormatException e) {\n        LOG.warn(\"Invalid GitLab project ID '{}' for ALM setting '{}': must be a valid number\",\n          projectAlmSetting.getAlmRepo(), almSetting.getKey(), e);\n      } catch (Exception e) {\n        LOG.warn(\"Failed to fetch GitLab repository URL for ALM setting '{}' and project ID '{}'\",\n          almSetting.getKey(), projectAlmSetting.getAlmRepo(), e);\n      }\n    }\n  }\n\n  private static void setBitbucketCloudRepositoryUrl(AlmSettingDto almSetting, ProjectAlmSettingDto projectAlmSetting, GetBindingWsResponse.Builder builder) {\n    String workspace = almSetting.getAppId();\n    String slug = projectAlmSetting.getAlmRepo();\n    if (isNotBlank(workspace) && isNotBlank(slug)) {\n      HttpUrl repositoryUrl = requireNonNull(HttpUrl.parse(BITBUCKET_CLOUD_ROOT_URL))\n        .newBuilder()\n        .addPathSegment(workspace)\n        .addPathSegment(slug)\n        .build();\n      builder.setRepositoryUrl(repositoryUrl.toString());","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java#L154-L190","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nalm_settings/set_binding?project=my_project&almRepo=group/my-repo\n// after\nalm_settings/set_binding?project=my_project&almRepo=42748211","handlingStrategy":"validation","validationCode":"// Validate the GitLab project id before binding\nString almRepo = projectAlmSetting.getAlmRepo();\nif (almRepo == null || !almRepo.matches(\"\\\\d+\")) {\n  throw new IllegalArgumentException(\"GitLab almRepo must be a numeric project ID, got: \" + almRepo);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["alm-integration","gitlab","number-format","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}