{"record":{"id":"2bee4801d8c82c7f","repo":"apache/seatunnel","slug":"get-index-docs-count-failed","errorCode":"GET_INDEX_DOCS_COUNT_FAILED","errorMessage":"GET ${endpoint} response null","messagePattern":"GET (.+?) response null","errorType":"error_code","errorClass":"EasysearchConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-easysearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/easysearch/client/EasysearchClient.java","lineNumber":443,"sourceCode":"                String fieldName = entry.getKey();\n                if (entry.getValue() instanceof TextNode) {\n                    doc.put(fieldName, entry.getValue().textValue());\n                } else {\n                    doc.put(fieldName, entry.getValue());\n                }\n            }\n            docs.add(doc);\n        }\n        return scrollResult;\n    }\n\n    public List<IndexDocsCount> getIndexDocsCount(String index) {\n        String endpoint = String.format(\"/_cat/indices/%s?h=index,docsCount&format=json\", index);\n        Request request = new Request(\"GET\", endpoint);\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new EasysearchConnectorException(\n                        EasysearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED,\n                        \"GET \" + endpoint + \" response null\");\n            }\n            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {\n                String entity = EntityUtils.toString(response.getEntity());\n                List<IndexDocsCount> indexDocsCounts =\n                        JsonUtils.toList(entity, IndexDocsCount.class);\n                return indexDocsCounts;\n            } else {\n                throw new EasysearchConnectorException(\n                        EasysearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED,\n                        String.format(\n                                \"GET %s response status code=%d\",\n                                endpoint, response.getStatusLine().getStatusCode()));\n            }\n        } catch (IOException ex) {\n            throw new EasysearchConnectorException(\n                    EasysearchConnectorErrorCode.GET_INDEX_DOCS_COUNT_FAILED, ex);","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-easysearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/easysearch/client/EasysearchClient.java#L425-L461","documentation":"getIndexDocsCount performs GET /_cat/indices/{index}?h=index,docsCount&format=json and throws GET_INDEX_DOCS_COUNT_FAILED when the REST client returns a null Response. As with the scroll path, null is treated as an anomalous transport result and fails fast to prevent NPEs on the status line.","triggerScenarios":"Called to fetch document counts for an index (e.g. during source catalog/split planning) and restClient.performRequest returns null.","commonSituations":"Intermittent load-balancer behavior returning empty responses, client/proxy misconfiguration, or custom interceptor stripping the response.","solutions":["Confirm the index name in config matches an existing index (wildcards allowed in _cat/indices)","Check proxies/LBs between SeaTunnel and the cluster for null-response behavior","Re-run the job; a transient transport glitch usually won't repeat","Capture REST client wire logs to see what preceded the null response"],"exampleFix":"// before\nif (response == null) { throw ... }\n// after\nif (response == null) { throw new EasysearchConnectorException(GET_INDEX_DOCS_COUNT_FAILED, \"GET \" + endpoint + \" response null\"); }\n// plus caller-side retry\nfor (int i = 0; i < 3 && count == null; i++) { try { count = client.getIndexDocsCount(index); } catch (EasysearchConnectorException e) { backoff(); } }","handlingStrategy":"retry","validationCode":"// check index exists before counting\nResponse head = restClient.performRequest(new Request(\"HEAD\", \"/\" + index));\nif (head.getStatusLine().getStatusCode() == 404) throw new IllegalStateException(\"index missing: \" + index);","typeGuard":"boolean valid(Response r) { return r != null && r.getStatusLine() != null; }","tryCatchPattern":"try { count = client.getIndexDocsCount(index); } catch (EasysearchConnectorException e) { count = backoffRetryOrDefault(3, 0L); }","preventionTips":["Confirm index names (and aliases) exist before job submission","Retry transient transport failures with exponential backoff","Keep network path free of flaky proxies","Log full response context when the anomaly occurs"],"tags":["http","null-response","index-count","easysearch"],"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-14T11:17:12.474Z"}