SonarSource/sonarqube · error · HttpException
Error %d on %s : %s
Error message
Error %d on %s : %s
What it means
BaseResponse.failIfNotSuccessful() checks the HTTP status of a web service response; when isSuccessful() is false it reads the body, closes the response, and throws HttpException(url, code, content). This is the library's way of converting a non-2xx HTTP response into a typed exception carrying the server's error payload.
Source
Thrown at sonar-ws/src/main/java/org/sonarqube/ws/client/BaseResponse.java:36
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonarqube.ws.client;
import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
abstract class BaseResponse implements WsResponse {
@Override
public boolean isSuccessful() {
return code() >= 200 && code() < 300;
}
@Override
public WsResponse failIfNotSuccessful() {
if (!isSuccessful()) {
String content = content();
close();
throw new HttpException(requestUrl(), code(), content);
}
return this;
}
@Override
public boolean hasContent() {
return code() != HTTP_NO_CONTENT;
}
@Override
public void close() {
// override if needed
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Inspect HttpException.code() and its body content to see the server's error message.
- Check authentication: verify the token is valid and not expired/revoked.
- Verify the user/agent has the permissions required for the endpoint.
- Validate request parameters (project keys, component ids) exist on the server before calling.
Example fix
// before
WsResponse response = wsClient.wsConnector().call(request);
response.failIfNotSuccessful();
// after
try (WsResponse response = wsClient.wsConnector().call(request)) {
response.failIfNotSuccessful();
} catch (HttpException e) {
if (e.code() == 404) { /* handle missing component */ }
else if (e.code() == 401) { /* refresh credentials */ }
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
response.failIfNotSuccessful();
} catch (org.sonarqube.ws.client.HttpException e) {
switch (e.code()) {
case 401: /* re-authenticate */ break;
case 403: /* check permissions */ break;
case 404: /* verify resource exists */ break;
default: throw e;
}
} Prevention
- Check response.code() or call isSuccessful() before consuming the body.
- Keep authentication tokens valid and scoped with required permissions.
- Validate resource identifiers (project/component keys) before sending requests.
When it happens
Trigger: Calling failIfNotSuccessful() on any WsResponse whose status code is not 2xx — e.g. 401 after an expired token, 403 for missing permissions, 404 for a nonexistent component/project key, or 400 for bad query parameters.
Common situations: Expired or invalid authentication tokens; calling a web service with a project/component key that doesn't exist; user lacking the required SonarQube permission; server-side validation rejecting request parameters.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- User is not authenticated
- Fail to download: %s
- Unsupported implementation: %s
- Fail to execute request '%s'. HTTP code: %s, response: %s
- Error while executing a call to %s. Return code %s. Error me
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/eb5ba2e20b040471.
Report an issue: GitHub.