{"record":{"id":"43aea400a9fad8cb","repo":"SonarSource/sonarqube","slug":"failed-to-get-gitlab-user","errorCode":null,"errorMessage":"Failed to get gitlab user","messagePattern":"Failed to get gitlab user","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabRestClient.java","lineNumber":41,"sourceCode":"import com.github.scribejava.core.model.Response;\nimport com.github.scribejava.core.oauth.OAuth20Service;\nimport java.io.IOException;\nimport org.sonar.auth.OAuthRestClient;\n\npublic class GitLabRestClient {\n\n  private final GitLabSettings gitLabSettings;\n\n  public GitLabRestClient(GitLabSettings gitLabSettings) {\n    this.gitLabSettings = gitLabSettings;\n  }\n\n  GsonUser getUser(OAuth20Service scribe, OAuth2AccessToken accessToken) {\n    try (Response response = OAuthRestClient.executeRequest(gitLabSettings.apiUrl() + \"/user\", scribe, accessToken)) {\n      String responseBody = response.getBody();\n      return GsonUser.parse(responseBody);\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Failed to get gitlab user\", e);\n    }\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":45,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabRestClient.java#L23-L45","documentation":"Thrown by GitLabRestClient.getUser when the HTTP call to the GitLab /user endpoint throws an IOException during request execution or body reading. The IllegalStateException wraps the IOException as its cause, indicating a transport-level failure rather than an API rejection (non-2xx responses are handled elsewhere).","triggerScenarios":"getUser(scribe, accessToken) executes OAuthRestClient.executeRequest(gitLabSettings.apiUrl() + \"/user\", ...) and the underlying HTTP client throws IOException — connection failure, timeout, TLS handshake error, or a broken response stream.","commonSituations":"Wrong sonar.auth.gitlab.url (pointing at the wrong host or missing /api prefix scheme); GitLab instance unreachable due to firewall/proxy; self-signed certificate not trusted by SonarQube's JVM; GitLab briefly down during maintenance.","solutions":["Inspect the chained IOException cause to determine whether it is DNS, connect, TLS, or read failure.","Verify sonar.auth.gitlab.url points to the correct GitLab base URL reachable from the SonarQube server (test with curl).","For self-signed GitLab instances, import the certificate into the JVM truststore used by SonarQube.","Check proxy settings and GitLab instance health; retry after transient outages."],"exampleFix":"// before\nsonar.auth.gitlab.url=https://gitlab.example.internal\n// after (correct scheme/host reachable from SonarQube, cert imported)\nsonar.auth.gitlab.url=https://gitlab.example.internal\n// and: keytool -importcert -alias gitlab -file gitlab.crt -keystore $JAVA_HOME/lib/security/cacerts","handlingStrategy":"retry","validationCode":"// Verify GitLab reachability from the SonarQube host before login\nHttpURLConnection c = (HttpURLConnection) new URL(gitLabSettings.apiUrl() + \"/user\").openConnection();\nc.setConnectTimeout(3000);","typeGuard":null,"tryCatchPattern":"try {\n    GsonUser user = gitLabRestClient.getUser(scribe, accessToken);\n} catch (IllegalStateException e) {\n    if (e.getCause() instanceof IOException io) {\n        LOG.warn(\"GitLab unreachable: {} — retry or check network/TLS\", io.getMessage());\n    }\n}","preventionTips":["Verify sonar.auth.gitlab.url is correct and reachable from the server (curl test).","Import self-signed GitLab certificates into the JVM truststore.","Configure proxy settings if the GitLab instance is behind a proxy."],"tags":["network","gitlab","rest-client","ioexception"],"backgroundTag":"network-request-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}