{"record":{"id":"a3b1b1e3b82f6bc4","repo":"apache/seatunnel","slug":"get-index-docs-count-failed-a3b1b1","errorCode":"GET_INDEX_DOCS_COUNT_FAILED","errorMessage":"GET {endpoint} response null","messagePattern":"GET (.+?) 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":559,"sourceCode":"        try {\n            Response response = restClient.performRequest(request);\n            int statusCode = response.getStatusLine().getStatusCode();\n            return statusCode == 200;\n        } catch (Exception ex) {\n            throw new ElasticsearchConnectorException(\n                    ElasticsearchConnectorErrorCode.CHECK_INDEX_FAILED, ex);\n        }\n    }\n\n    public List<IndexDocsCount> getIndexDocsCount(String index) {\n        String endpoint =\n                String.format(\n                        \"/_cat/indices/%s?h=index,docsCount&format=json\", index.toLowerCase());\n        Request request = new Request(\"GET\", endpoint);\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED,\n                        \"GET \" + endpoint + \" response null\");\n            }\n            String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);\n            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {\n                return JsonUtils.toList(entity, IndexDocsCount.class);\n            } else {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED,\n                        String.format(\n                                \"GET %s response status code=%d, body=%s\",\n                                endpoint, response.getStatusLine().getStatusCode(), entity));\n            }\n        } catch (IOException ex) {\n            throw new ElasticsearchConnectorException(\n                    ElasticsearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED, ex);\n        }\n    }","sourceCodeStart":541,"sourceCodeEnd":577,"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#L541-L577","documentation":"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.","triggerScenarios":"getIndexDocsCount / getIndexDocsCountSize path where restClient.performRequest returns null instead of a Response object.","commonSituations":"Custom or wrapped RestClient implementations that swallow responses; interceptors/proxies returning null on internal errors; unusual client versions where performRequest contract differs.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean hasResponse(Response r) { return r != null; }","tryCatchPattern":"try {\n    long count = client.getIndexDocsCountSize(indexName);\n} catch (ElasticsearchConnectorException e) {\n    if (e.getMessage().startsWith(\"GET \") && e.getMessage().contains(\"response null\")) {\n        // fall back to a direct search with track_total_hits\n        // or abort with a clear diagnostic about the client setup\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["elasticsearch","http","null-response","index-stats"],"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"}