apache/seatunnel · error · ElasticsearchConnectorException
GET_INDEX_DOCS_COUNT_FAILED
GET_INDEX_DOCS_COUNT_FAILED
Error message
GET {endpoint} response null What it means
Thrown when the GET /_cat/indices/{index}?h=index,docsCount&format=json request used to fetch the document count of an index returns a null Response from the Elasticsearch REST client. The library raises GET_INDEX_DOCS_COUNT_FAILED because it cannot read the count without a response. In practice a null response is rare and usually indicates a client/proxy anomaly.
Source
Thrown at seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java:559
try {
Response response = restClient.performRequest(request);
int statusCode = response.getStatusLine().getStatusCode();
return statusCode == 200;
} catch (Exception ex) {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.CHECK_INDEX_FAILED, ex);
}
}
public List<IndexDocsCount> getIndexDocsCount(String index) {
String endpoint =
String.format(
"/_cat/indices/%s?h=index,docsCount&format=json", index.toLowerCase());
Request request = new Request("GET", endpoint);
try {
Response response = restClient.performRequest(request);
if (response == null) {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED,
"GET " + endpoint + " response null");
}
String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return JsonUtils.toList(entity, IndexDocsCount.class);
} else {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED,
String.format(
"GET %s response status code=%d, body=%s",
endpoint, response.getStatusLine().getStatusCode(), entity));
}
} catch (IOException ex) {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED, ex);
}
}View on GitHub (pinned to cf67b549a7)
Solutions
- Check that the RestClient is built by the standard ES Low Level REST Client, not a wrapper that can return null
- Log/inspect the client configuration (httpHosts, auth, proxy) for anomalies
- Enable client tracing to see whether a request was actually sent and what came back
- If null persists, upgrade/align the elasticsearch-rest-client version used by the connector
Defensive patterns
Strategy: try-catch
Type guard
boolean hasResponse(Response r) { return r != null; } Try / catch
try {
long count = client.getIndexDocsCountSize(indexName);
} catch (ElasticsearchConnectorException e) {
if (e.getMessage().startsWith("GET ") && e.getMessage().contains("response null")) {
// fall back to a direct search with track_total_hits
// or abort with a clear diagnostic about the client setup
}
throw e;
} Prevention
- Avoid wrapping the RestClient in custom interceptors that can return null
- Keep the elasticsearch-rest-client version aligned with the connector's expectations
- Add integration smoke tests that call _cat endpoints before production runs
When it happens
Trigger: getIndexDocsCount / getIndexDocsCountSize path where restClient.performRequest returns null instead of a Response object.
Common situations: Custom or wrapped RestClient implementations that swallow responses; interceptors/proxies returning null on internal errors; unusual client versions where performRequest contract differs.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/a3b1b1e3b82f6bc4.
Report an issue: GitHub.