{"record":{"id":"1eb079f09ed974ff","repo":"apache/seatunnel","slug":"clear-index-data-failed","errorCode":"CLEAR_INDEX_DATA_FAILED","errorMessage":"POST {endpoint} response null","messagePattern":"POST (.+?) response null","errorType":"error_code","errorClass":"ElasticsearchConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java","lineNumber":671,"sourceCode":"                                \"DELETE %s response status code=%d, body=%s\",\n                                endpoint, response.getStatusLine().getStatusCode(), entity));\n            }\n        } catch (IOException ex) {\n            throw new ElasticsearchConnectorException(\n                    ElasticsearchConnectorErrorCode.DROP_INDEX_FAILED, ex);\n        }\n    }\n\n    public void clearIndexData(String indexName) {\n        String endpoint = String.format(\"/%s/_delete_by_query\", indexName.toLowerCase());\n        Request request = new Request(\"POST\", endpoint);\n        String jsonString = \"{ \\\"query\\\": { \\\"match_all\\\": {} } }\";\n        request.setJsonEntity(jsonString);\n\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.CLEAR_INDEX_DATA_FAILED,\n                        \"POST \" + endpoint + \" response null\");\n            }\n            String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);\n            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.CLEAR_INDEX_DATA_FAILED,\n                        String.format(\n                                \"POST %s response status code=%d, body=%s\",\n                                endpoint, response.getStatusLine().getStatusCode(), entity));\n            }\n        } catch (IOException ex) {\n            throw new ElasticsearchConnectorException(\n                    ElasticsearchConnectorErrorCode.CLEAR_INDEX_DATA_FAILED, ex);\n        }\n    }\n\n    /**","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java#L653-L689","documentation":"EsRestClient performs a POST request (delete-by-query with match_all to clear an index) via the low-level Elasticsearch RestClient and wraps every failure as ElasticsearchConnectorException with CLEAR_INDEX_DATA_FAILED. This specific variant is thrown when performRequest returns a null Response, which should not normally happen with the official client but is guarded defensively. It signals the clear-index operation could not even be evaluated because no HTTP response object came back.","triggerScenarios":"Calling EsRestClient clear-index/delete-by-query path (POST /{index}/_delete_by_query with {\"query\":{\"match_all\":{}}}) when org.elasticsearch.client.Response.restClient.performRequest(request) returns null.","commonSituations":"Custom or mocked RestClient implementations returning null; exotic proxies or network layers that abort the call without raising IOException; running against an incompatible/gateway front-end in front of Elasticsearch that swallows the request.","solutions":["Check network/proxy path between SeaTunnel and Elasticsearch; ensure the ES node actually receives the POST and answers","If a custom RestClient wrapper/mock is in play, make performRequest throw on failure instead of returning null","Retry the clear-index operation; transient gateway drops often succeed on retry","If the goal is clearing data, alternatively delete and recreate the index via the ES REST API directly to confirm cluster health"],"exampleFix":"// before\nResponse response = restClient.performRequest(request);\n// after\nResponse response = restClient.performRequest(request);\nif (response == null) {\n    throw new ElasticsearchConnectorException(\n        ElasticsearchConnectorErrorCode.CLEAR_INDEX_DATA_FAILED,\n        \"POST \" + endpoint + \" response null\");\n}","handlingStrategy":"try-catch","validationCode":"// pre-check ES reachability\ncurl -s -o /dev/null -w '%{http_code}' http://es:9200/<index>/_count\n// or in Java: perform a cheap HEAD /<index> request before clear-index","typeGuard":"// Java: narrow the client result before use\nif (response == null || response.getStatusLine() == null) {\n    throw new IOException(\"ES returned no response for \" + endpoint);\n}","tryCatchPattern":"try {\n    esRestClient.clearIndexData(index);\n} catch (ElasticsearchConnectorException e) {\n    if (e.getMessage().contains(\"response null\")) {\n        // log and retry with backoff; check network/proxy\n    } else { throw e; }\n}","preventionTips":["Avoid custom RestClient wrappers/mocks in production paths","Put a health check on the ES endpoint before running jobs","Ensure proxies/LBs between client and ES pass through DELETE_BY_QUERY without dropping responses","Use delete-and-recreate-index for large clears instead of delete_by_query"],"tags":["elasticsearch","http","null-response","delete-by-query"],"backgroundTag":"http-request-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}