{"record":{"id":"eb5ba2e20b040471","repo":"SonarSource/sonarqube","slug":"error-d-on-s-s","errorCode":null,"errorMessage":"Error %d on %s : %s","messagePattern":"Error (.+?) on (.+?) : (.+?)","errorType":"exception","errorClass":"HttpException","httpStatus":null,"severity":"error","filePath":"sonar-ws/src/main/java/org/sonarqube/ws/client/BaseResponse.java","lineNumber":36,"sourceCode":" * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n */\npackage org.sonarqube.ws.client;\n\nimport static java.net.HttpURLConnection.HTTP_NO_CONTENT;\n\nabstract class BaseResponse implements WsResponse {\n\n  @Override\n  public boolean isSuccessful() {\n    return code() >= 200 && code() < 300;\n  }\n\n  @Override\n  public WsResponse failIfNotSuccessful() {\n    if (!isSuccessful()) {\n      String content = content();\n      close();\n      throw new HttpException(requestUrl(), code(), content);\n    }\n    return this;\n  }\n\n  @Override\n  public boolean hasContent() {\n    return code() != HTTP_NO_CONTENT;\n  }\n\n  @Override\n  public void close() {\n    // override if needed\n  }\n}\n","sourceCodeStart":18,"sourceCodeEnd":51,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseResponse.java#L18-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nWsResponse response = wsClient.wsConnector().call(request);\nresponse.failIfNotSuccessful();\n// after\ntry (WsResponse response = wsClient.wsConnector().call(request)) {\n  response.failIfNotSuccessful();\n} catch (HttpException e) {\n  if (e.code() == 404) { /* handle missing component */ }\n  else if (e.code() == 401) { /* refresh credentials */ }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  response.failIfNotSuccessful();\n} catch (org.sonarqube.ws.client.HttpException e) {\n  switch (e.code()) {\n    case 401: /* re-authenticate */ break;\n    case 403: /* check permissions */ break;\n    case 404: /* verify resource exists */ break;\n    default: throw e;\n  }\n}","preventionTips":["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."],"tags":["http","api","sonarqube"],"backgroundTag":"http-error-response","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"}