{"record":{"id":"7bb2328ec4655a1f","repo":"SonarSource/sonarqube","slug":"fail-to-download-s","errorCode":null,"errorMessage":"Fail to download: %s","messagePattern":"Fail to download: (.+?)","errorType":"exception","errorClass":"SonarException","httpStatus":null,"severity":"error","filePath":"sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java","lineNumber":153,"sourceCode":"  }\n\n  private Response executeCall(URI uri) throws IOException {\n    Request request = new Request.Builder().url(uri.toURL()).get().build();\n    Response response = client.newCall(request).execute();\n    throwExceptionIfResponseIsNotSuccesful(uri, response);\n    return response;\n  }\n\n  private static void throwExceptionIfResponseIsNotSuccesful(URI uri, Response response) throws IOException {\n    if (!response.isSuccessful()) {\n      try (ResponseBody responseBody = response.body()) {\n        throw new HttpException(uri, response.code(), responseBody.string());\n      }\n    }\n  }\n\n  private static SonarException failToDownload(URI uri, IOException e) {\n    throw new SonarException(String.format(\"Fail to download: %s\", uri), e);\n  }\n\n}\n","sourceCodeStart":135,"sourceCodeEnd":157,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java#L135-L157","documentation":"DefaultHttpDownloader throws this SonarException (wrapped in an HttpException carrying the URI, HTTP status code and response body) when an HTTP download from a remote server fails. It is raised by failToDownload in two cases: any IOException while opening/reading the connection, or a non-successful HTTP response code from the server. The message includes the exact URI that could not be downloaded.","triggerScenarios":"Calling DefaultHttpDownloader.readString(), download(), or openStream() when the target URI is unreachable (DNS failure, connection refused, timeout) or when the server returns a non-2xx status code (404 not found, 403 forbidden, 500 server error).","commonSituations":"SonarQube server URL misconfigured in sonar.properties; plugin/update-center downloads failing due to a proxy or firewall blocking outbound HTTPS; the remote resource was moved or deleted (404); SSL certificate issues in corporate environments; SonarQube server temporarily down during CI analysis.","solutions":["Open the URI from the message in a browser or with curl to see the actual HTTP status/error.","Verify sonar.host.url / sonar.server base URL and network connectivity (DNS, proxy, firewall) from the machine running the download.","If behind a corporate proxy, configure proxy settings for the JVM/analysis process.","Check whether the resource still exists on the server (e.g. plugin update center) and use a valid URL/version.","Check SSL/TLS: add the server certificate to the truststore or fix the keystore configuration if certificate validation fails."],"exampleFix":"// before: assuming download always succeeds\nString xml = downloader.readString(URI.create(serverUrl + \"/api/rules/show\"));\n// after: pre-check reachability and handle failure\nURI uri = URI.create(serverUrl + \"/api/rules/show\");\ntry {\n  String xml = downloader.readString(uri);\n} catch (SonarException e) {\n  LOG.warn(\"Could not download \" + uri + \": \" + e.getMessage());\n}","handlingStrategy":"retry","validationCode":"HttpURLConnection c = (HttpURLConnection) uri.toURL().openConnection();\nc.setConnectTimeout(5000);\nif (c.getResponseCode() / 100 != 2) {\n  throw new IllegalStateException(\"Resource unavailable: \" + c.getResponseCode());\n}","typeGuard":null,"tryCatchPattern":"try {\n  String content = downloader.readString(uri);\n} catch (SonarException e) {\n  // inspect e.getCause() instanceof HttpException for status code\n  LOG.warn(\"Download failed for \" + uri, e);\n}","preventionTips":["Validate the server URL and resource path before analysis runs","Configure proxy/SSL settings for environments with egress restrictions","Monitor the remote endpoint's availability in CI","Cache downloaded resources locally to reduce dependence on network"],"tags":["network","http","download","sonarqube"],"backgroundTag":"http-request-failed","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"}