{"record":{"id":"7682ee5153e955a8","repo":"apache/seatunnel","slug":"search-with-pit-failed","errorCode":"SEARCH_WITH_PIT_FAILED","errorMessage":"POST /_search response null","messagePattern":"POST /_search 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":1074,"sourceCode":"        // Add search_after if provided\n        if (searchAfter != null && searchAfter.length > 0) {\n            requestBody.put(\"search_after\", searchAfter);\n        }\n        if (sliceMax != null && sliceMax > 1) {\n            Map<String, Object> slice = new HashMap<>();\n            slice.put(\"id\", sliceId == null ? 0 : sliceId);\n            slice.put(\"max\", sliceMax);\n            requestBody.put(\"slice\", slice);\n        }\n\n        String endpoint = \"/_search\";\n        Request request = new Request(\"POST\", endpoint);\n        request.setJsonEntity(JsonUtils.toJsonString(requestBody));\n\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.SEARCH_WITH_PIT_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                return parsePointInTimeResponse(entity, pitId);\n            } else {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.SEARCH_WITH_PIT_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.SEARCH_WITH_PIT_FAILED, ex);\n        }\n    }","sourceCodeStart":1056,"sourceCodeEnd":1092,"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#L1056-L1092","documentation":"EsRestClient throws this when the low-level RestClient.performRequest returns null for a POST /_search request executed with a Point-in-Time context. Since a successful HTTP call never yields a null Response, this indicates an unexpected client/transport state, and the connector fails fast with SEARCH_WITH_PIT_FAILED.","triggerScenarios":"Calling the PIT search method when the underlying RestClient returns null from performRequest — typically only in unusual transport or mocked-client situations.","commonSituations":"Custom or wrapped RestClient implementations (proxies, test doubles) that return null instead of throwing; edge cases in connection handling inside the ES Java client.","solutions":["Inspect how the RestClient is built — replace any custom wrapper or mock that can return null from performRequest","Enable debug logging on the ES RestClient to see the request lifecycle before the null response","Ensure the standard org.elasticsearch.client.RestClient is used without unusual interceptors that swallow responses"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the RestClient is a real, started instance before searching:\nObjects.requireNonNull(restClient, \"RestClient must be initialized before PIT search\");","typeGuard":"boolean hasResponse(Response r) { return r != null && r.getStatusLine() != null; }","tryCatchPattern":"try {\n    result = esClient.searchWithPit(requestBody, pitId);\n} catch (ElasticsearchConnectorException e) {\n    if (String.valueOf(e.getMessage()).contains(\"response null\")) {\n        throw new IllegalStateException(\"RestClient returned null; check client init/interceptors\", e);\n    }\n    throw e;\n}","preventionTips":["Use the standard Elasticsearch RestClient without wrappers that can return null","Retry with backoff on transport anomalies","Fail fast at startup if the RestClient failed to initialize"],"tags":["elasticsearch","http","point-in-time","null-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}