{"record":{"id":"987dfe1e1d4b1c05","repo":"apache/beam","slug":"cannot-get-elasticsearch-version","errorCode":null,"errorMessage":"Cannot get Elasticsearch version","messagePattern":"Cannot get Elasticsearch version","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java","lineNumber":3023,"sourceCode":"  static int getBackendVersion(RestClient restClient) {\n    try {\n      Request request = new Request(\"GET\", \"\");\n      Response response = restClient.performRequest(request);\n      JsonNode jsonNode = parseResponse(response.getEntity());\n      int backendVersion =\n          Integer.parseInt(jsonNode.path(\"version\").path(\"number\").asText().substring(0, 1));\n      checkArgument(\n          VALID_CLUSTER_VERSIONS.contains(backendVersion),\n          \"The Elasticsearch version to connect to is %s.x. \"\n              + \"This version of the ElasticsearchIO is only compatible with \"\n              + \"Elasticsearch \"\n              + VALID_CLUSTER_VERSIONS,\n          backendVersion);\n      maybeLogVersionDeprecationWarning(backendVersion);\n      return backendVersion;\n\n    } catch (IOException e) {\n      throw new IllegalArgumentException(\"Cannot get Elasticsearch version\", e);\n    }\n  }\n\n  static int getBackendVersion(ConnectionConfiguration connectionConfiguration) {\n    try (RestClient restClient = connectionConfiguration.createClient()) {\n      return getBackendVersion(restClient);\n    } catch (IOException e) {\n      throw new IllegalArgumentException(\"Cannot get Elasticsearch version\", e);\n    }\n  }\n}\n","sourceCodeStart":3005,"sourceCodeEnd":3035,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java#L3005-L3035","documentation":"getBackendVersion(RestClient) queries the cluster's root endpoint to read version.number and map it to an internal backend version constant. If the HTTP request itself fails (connection error, timeout, non-parseable response producing IOException), the IOException is wrapped into an IllegalArgumentException with this message. It means the library could not talk to or understand the Elasticsearch cluster.","triggerScenarios":"ElasticsearchIO.read()/write() pipeline validation calling static getBackendVersion when the RestClient request fails: wrong host/port, TLS failure, network unreachable, or malformed version response.","commonSituations":"Typo in ES address; cluster not reachable from the Beam worker (VPC/firewall); cluster returns unexpected JSON because a proxy intercepts; unsupported/newer ES version returning an unparsable body.","solutions":["Inspect the wrapped IOException cause for the network/connection error","Verify ConnectionConfiguration host, port, scheme (http/https) and credentials","Test connectivity: `curl -u user:pass https://es-host:9200/` from the worker environment","Confirm the response's version.number is a supported version (VALID_CLUSTER_VERSIONS)","Ensure no proxy/load balancer is returning a non-ES response body"],"exampleFix":"// before\nConnectionConfiguration.create(\"localhost\", 9200) // unreachable from worker\n// after\nConnectionConfiguration.create(\"elasticsearch.es.svc.cluster.local\", 9200)","handlingStrategy":"validation","validationCode":"try (RestClient c = connectionConfiguration.createClient()) {\n  Response r = c.performRequest(new Request(\"GET\", \"/\"));\n  if (r.getStatusLine().getStatusCode() != 200)\n    throw new IllegalStateException(\"ES root returned \" + r.getStatusLine());\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.run();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Cannot get Elasticsearch version\"))\n    LOG.error(\"ES unreachable during validation: {}\", e.getCause());\n  throw e;\n}","preventionTips":["Health-check the cluster (curl /_cluster/health) before launching the pipeline","Pin the ES host in one shared ConnectionConfiguration constant","Ensure workers have network egress to the ES cluster (VPC rules)"],"tags":["java","elasticsearch","beam","connectivity"],"backgroundTag":"http-request-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}