SonarSource/sonarqube · error · IllegalStateException

SonarQube was not able to retrieve resources from external s

Error message

SonarQube was not able to retrieve resources from external system. Error while executing a paginated call to %s, endpoint:%s. 

What it means

This is the wrapper thrown by executeCall's catch(Exception) block: any failure while executing a paginated call (non-2xx response, network error, invalid URL) is logged with full detail and rethrown as an IllegalStateException prefixed with 'SonarQube was not able to retrieve resources from external system'. The original cause message is appended.

Source

Thrown at server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericPaginatedHttpClient.java:89

    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      LOG.warn(format("Thread interrupted: %s", e.getMessage()), e);
    }
  }

  private GetResponse executeCall(String appUrl, AccessToken token, String endpoint) {
    try {
      GetResponse response = appHttpClient.get(appUrl, token, endpoint);
      if (response.getCode() < 200 || response.getCode() >= 300) {
        throw new IllegalStateException(
          format("Error while executing a call to %s. Return code %s. Error message: %s.", appUrl, response.getCode(), response.getContent().orElse("")));
      }
      return response;
    } catch (Exception e) {
      String errorMessage = format("SonarQube was not able to retrieve resources from external system. Error while executing a paginated call to %s, endpoint:%s.",
        appUrl, endpoint);
      logException(errorMessage, e);
      throw new IllegalStateException(errorMessage + " " + e.getMessage());
    }
  }

  private static void logException(String message, Exception e) {
    if (LOG.isDebugEnabled()) {
      LOG.warn(message, e);
    } else {
      LOG.warn(message, e.getMessage());
    }
  }
}

View on GitHub (pinned to 184c821202)

Solutions

  1. Read the appended cause and the WARN log line (logException) to find the root error, then fix it specifically.
  2. Test connectivity from the SonarQube host: curl the configured appUrl endpoint.
  3. If TLS-related, import the ALM server certificate into the JVM truststore.
  4. Re-check the DevOps platform integration settings (URL, token) and retry the import.

Example fix

// before
URL=http://internal-azure (unreachable from SonarQube host)

// after
URL=https://devops.internal.example.com (resolvable and reachable)
Defensive patterns

Strategy: try-catch

Validate before calling

static boolean canReach(String appUrl) {
  try {
    HttpURLConnection c = (HttpURLConnection) new java.net.URI(appUrl).toURL().openConnection();
    c.setConnectTimeout(5000);
    return c.getResponseCode() > 0;
  } catch (Exception e) { return false; }
}

Try / catch

try {
  items = paginatedClient.listAll(appUrl, token, endpoint);
} catch (IllegalStateException e) {
  // message is "SonarQube was not able to retrieve resources ..." + cause
  LOG.warn("Devops import failed: {}", e.getMessage());
  // fall back to last synced data
  items = lastKnownSnapshot();
}

Prevention

When it happens

Trigger: Any exception inside the paginated GET: IllegalStateException from a non-2xx code (see executeCall), IOException/connection failure to the ALM host, IllegalArgumentException from an invalid URL, or response-body reading failure.

Common situations: ALM server unreachable (DNS/firewall), TLS certificate not trusted by SonarQube's JVM, expired PAT causing 401, misconfigured URL after migrating the ALM server.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/d1bf480b265d60ab. Report an issue: GitHub.