{"record":{"id":"13a0ccb17abd28c7","repo":"elastic/elasticsearch","slug":"method-s-host-s-uri-s-status-line-s","errorCode":null,"errorMessage":"method [%s], host [%s], URI [%s], status line [%s]","messagePattern":"method \\[(.+?)\\], host \\[(.+?)\\], URI \\[(.+?)\\], status line \\[(.+?)\\]","errorType":"exception","errorClass":"WarningFailureException","httpStatus":null,"severity":"error","filePath":"client/rest/src/main/java/org/elasticsearch/client/RestClient.java","lineNumber":347,"sourceCode":"        RequestLogger.logResponse(logger, request.httpRequest, node.getHost(), httpResponse);\n        int statusCode = httpResponse.getStatusLine().getStatusCode();\n\n        HttpEntity entity = httpResponse.getEntity();\n        if (entity != null) {\n            Header header = entity.getContentEncoding();\n            if (header != null && \"gzip\".equals(header.getValue())) {\n                // Decompress and cleanup response headers\n                httpResponse.setEntity(new GzipDecompressingEntity(entity));\n                httpResponse.removeHeaders(HTTP.CONTENT_ENCODING);\n                httpResponse.removeHeaders(HTTP.CONTENT_LEN);\n            }\n        }\n\n        Response response = new Response(request.httpRequest.getRequestLine(), node.getHost(), httpResponse);\n        if (isSuccessfulResponse(statusCode) || request.ignoreErrorCodes.contains(response.getStatusLine().getStatusCode())) {\n            onResponse(node);\n            if (request.warningsHandler.warningsShouldFailRequest(response.getWarnings())) {\n                throw new WarningFailureException(response);\n            }\n            return new ResponseOrResponseException(response);\n        }\n        ResponseException responseException = new ResponseException(response);\n        if (isRetryStatus(statusCode)) {\n            // mark host dead and retry against next one\n            onFailure(node);\n            return new ResponseOrResponseException(responseException);\n        }\n        // mark host alive and don't retry, as the error should be a request problem\n        onResponse(node);\n        throw responseException;\n    }\n\n    /**\n     * Sends a request to the Elasticsearch cluster that the client points to.\n     * The request is executed asynchronously and the provided\n     * {@link ResponseListener} gets notified upon request completion or","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/client/rest/src/main/java/org/elasticsearch/client/RestClient.java#L329-L365","documentation":"This is the message format of ResponseException, thrown by RestClient.convertResponse when an Elasticsearch node replies with a non-success, non-retryable HTTP status (e.g. 4xx client errors). buildMessage formats the request method, host, URI, and status line into the exception text, then appends any warnings and the response body so the caller sees why the request was rejected.","triggerScenarios":"Any request that returns a 4xx (or non-retryable error) status: malformed query JSON (400), missing index (404), auth failure (401/403), mapping conflict (400), etc. The exception is thrown at the end of convertResponse after marking the host alive.","commonSituations":"Query syntax error; referencing a non-existent index/alias; insufficient permissions; version conflict on update; oversized request; misconfigured mapping.","solutions":["Catch ResponseException, inspect getResponse().getStatusLine().getStatusCode() and the body to diagnose the underlying ES error.","Fix the request per the ES error: correct query JSON, ensure index exists, grant permissions, resolve conflicts.","For expected 404s, check getResponse().getStatusLine().getStatusCode() == 404 and handle gracefully instead of propagating."],"exampleFix":"// before\nResponse r = client.performRequest(req); // throws ResponseException on 404\n// after\ntry {\n    Response r = client.performRequest(req);\n} catch (ResponseException e) {\n    if (e.getResponse().getStatusLine().getStatusCode() == 404) {\n        // index not found - handle gracefully\n    } else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Response r = client.performRequest(req);\n} catch (ResponseException e) {\n    int code = e.getResponse().getStatusLine().getStatusCode();\n    switch (code) {\n        case 404: // not found - handle absent resource\n        case 409: // conflict - retry or surface\n        default: throw e;\n    }\n}","preventionTips":["Validate query JSON, index names, and mappings before sending requests.","Inspect the status code and body in the catch to branch on expected vs unexpected errors.","Handle common statuses (404, 409, 401/403) explicitly rather than propagating generic ResponseException."],"tags":["rest-client","http","response","error-handling"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}