{"record":{"id":"74e3762de8d20b73","repo":"apache/seatunnel","slug":"add-field-failed","errorCode":"ADD_FIELD_FAILED","errorMessage":"PUT {endpoint} response null","messagePattern":"PUT (.+?) 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":896,"sourceCode":"                    .getType()\n                    .equalsIgnoreCase(AGGREGATE_METRIC_DOUBLE)) {\n                ArrayNode metricsArray = OBJECT_MAPPER.createArrayNode();\n                @SuppressWarnings(\"unchecked\")\n                List<String> metrics = (List<String>) options.get(\"metrics\");\n                metrics.forEach(metricsArray::add);\n                fieldJson.set(\"metrics\", metricsArray);\n            }\n        }\n\n        propertiesJson.set(fieldTypeDefine.getName(), fieldJson);\n        mappingJson.set(\"properties\", propertiesJson);\n\n        request.setJsonEntity(mappingJson.toString());\n\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.ADD_FIELD_FAILED,\n                        \"PUT \" + endpoint + \" response null\");\n            }\n            String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);\n            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.ADD_FIELD_FAILED,\n                        String.format(\n                                \"PUT %s response status code=%d, body=%s\",\n                                endpoint, response.getStatusLine().getStatusCode(), entity));\n            }\n        } catch (IOException ex) {\n            throw new ElasticsearchConnectorException(\n                    ElasticsearchConnectorErrorCode.ADD_FIELD_FAILED,\n                    String.format(\n                            \"Failed to add field %s to index %s\", fieldTypeDefine.getName(), index),\n                    ex);\n        }","sourceCodeStart":878,"sourceCodeEnd":914,"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#L878-L914","documentation":"EsRestClient adds/updates a field by PUTting a mapping update to the index; if performRequest returns a null Response it throws ADD_FIELD_FAILED. This means the mapping-update request never yielded an HTTP answer, so the new field could not be applied to the index schema.","triggerScenarios":"Calling the addField path (PUT /{index}/_mapping with the field's mapping JSON) when restClient.performRequest(request) returns null.","commonSituations":"Custom/mock RestClient returning null; connection dropped by a proxy mid-request; wrapped client versions where the null case is reachable during network faults.","solutions":["Verify the ES cluster is reachable and the PUT /{index}/_mapping call works with curl","Retry the job — auto-add-field is often transient-safe once connectivity is restored","If using a custom client wrapper, ensure it throws IOException rather than returning null","Pre-create the field mapping in the index definition so runtime addField is unnecessary"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check the index accepts mapping updates\ncurl -s -u user:pass 'es:9200/<index>/_settings?filter_path=*.blocks*'\ncurl -s -o /dev/null -w '%{http_code}' 'es:9200/<index>'","typeGuard":"if (response == null) { throw new IOException(\"null response for mapping PUT on \" + index); }","tryCatchPattern":"try {\n    esRestClient.addField(index, fieldTypeDefine);\n} catch (ElasticsearchConnectorException e) {\n    // retry with backoff; check cause for network faults\n}","preventionTips":["Keep ES reachable and sized for the job (no GC storms causing dropped connections)","Pre-define all fields in the index mapping to avoid runtime addField","Avoid proxies that can sever long-running client connections","Pin a stable ES client version compatible with your cluster"],"tags":["elasticsearch","http","null-response","mapping-update"],"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"}