{"record":{"id":"ce2e36e165ac559d","repo":"SonarSource/sonarqube","slug":"cannot-mint-a-gitlab-access-token-project-ha-ce2e36","errorCode":null,"errorMessage":"Cannot mint a GitLab access token: project '{}' has a non-numeric GitLab repository identifier '{}'","messagePattern":"Cannot mint a GitLab access token: project '(.+?)' has a non-numeric GitLab repository identifier '(.+?)'","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabScmAccessTokenProvider.java","lineNumber":192,"sourceCode":"\n  private static boolean isExpiring(ScmAccessToken token) {\n    try {\n      return token.expiresAt() == null || !LocalDate.parse(token.expiresAt()).isAfter(LocalDate.now(ZoneOffset.UTC).plusDays(TOKEN_ROTATION_MARGIN_DAYS));\n    } catch (DateTimeParseException e) {\n      return true;\n    }\n  }\n\n  @Nullable\n  private static Long parseGitlabProjectId(@Nullable String almRepo, String safeProjectKey) {\n    if (almRepo == null || almRepo.isBlank()) {\n      LOG.warn(\"Cannot mint a GitLab access token: project '{}' has no repository configured on its DevOps Platform binding\", safeProjectKey);\n      return null;\n    }\n    try {\n      return Long.parseLong(almRepo);\n    } catch (NumberFormatException e) {\n      LOG.warn(\"Cannot mint a GitLab access token: project '{}' has a non-numeric GitLab repository identifier '{}'\", safeProjectKey, sanitizeForLog(almRepo));\n      return null;\n    }\n  }\n\n  private static String formatExpiresAt(@Nullable String responseExpiresAt, LocalDate requestedExpiresAt) {\n    if (responseExpiresAt != null && !responseExpiresAt.isBlank()) {\n      try {\n        return LocalDate.parse(responseExpiresAt.trim()).format(DateTimeFormatter.ISO_LOCAL_DATE);\n      } catch (DateTimeParseException e) {\n        LOG.warn(\"GitLab returned an unparseable token expiry '{}', falling back to the requested date\", sanitizeForLog(responseExpiresAt));\n      }\n    }\n    return requestedExpiresAt.format(DateTimeFormatter.ISO_LOCAL_DATE);\n  }\n\n  private static String sanitizeForLog(String value) {\n    return CRLF_PATTERN.matcher(value).replaceAll(\"_\");\n  }","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabScmAccessTokenProvider.java#L174-L210","documentation":"parseGitlabProjectId() expects the stored almRepo to be the numeric GitLab project identifier. Long.parseLong() throws NumberFormatException for non-numeric values; the code catches it, logs this warning (with the value sanitized), and returns null so minting aborts.","triggerScenarios":"Calling mint() for a project whose ALM binding stores a repository value like 'group/project' (path-style) or any non-numeric string instead of the numeric GitLab project id.","commonSituations":"Binding configured with the GitLab repository path instead of its numeric id; older SonarQube versions or manual API writes that stored slug values; copy-paste of the repo URL rather than the id.","solutions":["Replace the binding's repository value with the numeric GitLab project id (visible on the GitLab project page under the name, or via GET /api/v4/projects/<path-with-slashes-encoded>).","Re-run the binding import (api/alm_settings/import_bindings) so SonarQube resolves numeric ids from GitLab.","Delete and re-set the binding via api/alm_settings/set_gitlab with the numeric id.","Validate the value is numeric before saving bindings to prevent recurrence."],"exampleFix":"// before\napi/alm_settings/set_gitlab {..., gitlabProjectId: 'my-group/my-project'}\n// after\napi/alm_settings/set_gitlab {..., gitlabProjectId: '12345'}","handlingStrategy":"validation","validationCode":"// Java\nString almRepo = binding.getAlmRepo();\nLong.parseLong(almRepo); // throws NumberFormatException early if non-numeric","typeGuard":"boolean isNumericGitlabProjectId(String almRepo) {\n  try { Long.parseLong(almRepo); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Store numeric GitLab project ids, never 'group/project' paths.","Fetch the numeric id via GET /api/v4/projects/<url-encoded-path> when configuring bindings.","Validate numeric format when accepting binding input.","Prefer the binding import API, which resolves ids automatically."],"tags":["gitlab","invalid-identifier","number-format","token-minting"],"backgroundTag":"invalid-argument-format","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}