apache/seatunnel · error · ElasticsearchConnectorException
SEARCH_WITH_PIT_FAILED
SEARCH_WITH_PIT_FAILED
Error message
POST /_search response null
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java:1074
// Add search_after if provided
if (searchAfter != null && searchAfter.length > 0) {
requestBody.put("search_after", searchAfter);
}
if (sliceMax != null && sliceMax > 1) {
Map<String, Object> slice = new HashMap<>();
slice.put("id", sliceId == null ? 0 : sliceId);
slice.put("max", sliceMax);
requestBody.put("slice", slice);
}
String endpoint = "/_search";
Request request = new Request("POST", endpoint);
request.setJsonEntity(JsonUtils.toJsonString(requestBody));
try {
Response response = restClient.performRequest(request);
if (response == null) {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.SEARCH_WITH_PIT_FAILED,
"POST " + endpoint + " response null");
}
String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return parsePointInTimeResponse(entity, pitId);
} else {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.SEARCH_WITH_PIT_FAILED,
String.format(
"POST %s response status code=%d, body=%s",
endpoint, response.getStatusLine().getStatusCode(), entity));
}
} catch (IOException ex) {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.SEARCH_WITH_PIT_FAILED, ex);
}
}View on GitHub (pinned to cf67b549a7)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the RestClient is a real, started instance before searching: Objects.requireNonNull(restClient, "RestClient must be initialized before PIT search");
Type guard
boolean hasResponse(Response r) { return r != null && r.getStatusLine() != null; } Try / catch
try {
result = esClient.searchWithPit(requestBody, pitId);
} catch (ElasticsearchConnectorException e) {
if (String.valueOf(e.getMessage()).contains("response null")) {
throw new IllegalStateException("RestClient returned null; check client init/interceptors", e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: Calling the PIT search method when the underlying RestClient returns null from performRequest — typically only in unusual transport or mocked-client situations.
Common situations: Custom or wrapped RestClient implementations (proxies, test doubles) that return null instead of throwing; edge cases in connection handling inside the ES Java client.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- GET_INDEX_DOCS_COUNT_FAILED
- LIST_INDEX_FAILED
- CREATE_INDEX_FAILED
- DROP_INDEX_FAILED
- CLEAR_INDEX_DATA_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/7682ee5153e955a8.
Report an issue: GitHub.