{"record":{"id":"a4e98fee0ea8ca63","repo":"SonarSource/sonarqube","slug":"failed-to-get-s","errorCode":null,"errorMessage":"Failed to get %s","messagePattern":"Failed to get (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-auth-common/src/main/java/org/sonar/auth/OAuthRestClient.java","lineNumber":85,"sourceCode":"    readPage(result, scribe, accessToken, addPerPageQueryParameter(request, DEFAULT_PAGE_SIZE), function);\n    return result;\n  }\n\n  public static String addPerPageQueryParameter(String request, int pageSize) {\n    String separator = request.contains(\"?\") ? \"&\" : \"?\";\n    return request + separator + \"per_page=\" + pageSize;\n  }\n\n  private static <E> void readPage(List<E> result, OAuth20Service scribe, OAuth2AccessToken accessToken, String endPoint, Function<String, List<E>> function) {\n    try (Response nextResponse = executeRequest(endPoint, scribe, accessToken)) {\n      String content = nextResponse.getBody();\n      if (content == null) {\n        return;\n      }\n      result.addAll(function.apply(content));\n      readNextEndPoint(nextResponse).ifPresent(newNextEndPoint -> readPage(result, scribe, accessToken, newNextEndPoint, function));\n    } catch (IOException e) {\n      throw new IllegalStateException(format(\"Failed to get %s\", endPoint), e);\n    }\n  }\n\n  private static Optional<String> readNextEndPoint(Response response) {\n    String link = response.getHeaders().entrySet().stream()\n      .filter(e -> \"Link\".equalsIgnoreCase(e.getKey()))\n      .map(Map.Entry::getValue)\n      .findAny().orElse(\"\");\n\n    Matcher nextLinkMatcher = NEXT_LINK_PATTERN.matcher(link);\n    if (!nextLinkMatcher.find()) {\n      return Optional.empty();\n    }\n    return Optional.of(nextLinkMatcher.group(1));\n  }\n\n  private static IllegalStateException unexpectedResponseCode(String requestUrl, Response response) throws IOException {\n    return new IllegalStateException(format(\"Fail to execute request '%s'. HTTP code: %s, response: %s\", requestUrl, response.getCode(), response.getBody()));","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-auth-common/src/main/java/org/sonar/auth/OAuthRestClient.java#L67-L103","documentation":"Thrown by OAuthRestClient.readPage when an IOException occurs while fetching a page of a paginated REST endpoint (used e.g. by Bitbucket/GitHub organization or workspace lookups). The failing endPoint URL is embedded in the message and the IOException is chained as the cause.","triggerScenarios":"executePaginatedRequest follows Link headers page by page; any page fetch that throws IOException (connection reset, timeout, DNS failure, TLS error, stream read failure) is wrapped in this IllegalStateException.","commonSituations":"Network instability between SonarQube and the identity provider API; proxy/firewall blocking subsequent page requests; rate limiting closing connections; incorrect apiURL host unreachable.","solutions":["Inspect the chained cause (IOException) and endPoint in the message to identify the unreachable URL and network failure mode.","Verify network/proxy connectivity from the SonarQube server to the identity provider API host.","Confirm apiURL points to a reachable, correct base URL.","Retry after transient network issues; check API rate limits if failures are persistent."],"exampleFix":"// before\nreadNextEndPoint(nextResponse).ifPresent(newNextEndPoint -> readPage(result, scribe, accessToken, newNextEndPoint, function));\n// after (guard with retry for transient failures)\nreadNextEndPoint(nextResponse).ifPresent(newNextEndPoint -> {\n  try {\n    readPage(result, scribe, accessToken, newNextEndPoint, function);\n  } catch (IllegalStateException e) {\n    LOG.warn(\"Retrying page fetch for {}\", newNextEndPoint, e);\n    readPage(result, scribe, accessToken, newNextEndPoint, function);\n  }\n});","handlingStrategy":"retry","validationCode":"// Reachability pre-check before paginated calls\ntry (Socket s = new Socket()) {\n    s.connect(new InetSocketAddress(host, 443), 3000); // fails fast if unreachable\n}","typeGuard":null,"tryCatchPattern":"try {\n    executePaginatedRequest(...);\n} catch (IllegalStateException e) {\n    if (e.getCause() instanceof IOException io) {\n        LOG.warn(\"Paginated fetch failed for {}, retrying once\", e.getMessage(), io);\n    }\n}","preventionTips":["Ensure stable network/proxy connectivity from SonarQube to the API host.","Watch API rate limits that can terminate long pagination runs.","Keep timeouts generous enough for multi-page responses."],"tags":["network","rest-client","pagination","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"}