apache/beam · warning
Could not extract error codes from responseEntity
Error message
Could not extract error codes from responseEntity {} What it means
In ElasticsearchIO's RetryConfiguration error-code extractor, the code tries to parse the error response entity to find per-item HTTP status values and compare them to a predicate error code. If reading the entity content throws IOException, parsing fails and it logs this warning, returning false (the response is not treated as retryable). The actual write error is surfaced elsewhere; this warning means the retry predicate could not classify the error.
Solutions
- Check network stability between the Beam worker and Elasticsearch; truncated responses cause this.
- Inspect the logged responseEntity to understand the underlying server error.
- Adjust RetryConfiguration to retry on exceptions (e.g. retryPredicates covering IOExceptions) instead of relying only on status codes.
- Ensure Elasticsearch returns well-formed error bodies (check server/proxy logs for truncation).
Example fix
// before: only classifies by parsed status codes, warns on parse failure RetryConfiguration.retryPredicates(); // after: also retry on IO errors explicitly .withRetryStrategy(new ElasticsearchIO.RetryStrategy(10, 1000)) .withMaxCumulativeAttempts(10); // plus ensure network stability
Defensive patterns
Strategy: retry
Try / catch
// the retry predicate swallows the IOException internally; configure resilient retries at the sink .withRetryConfiguration(ElasticsearchIO.RetryConfiguration.create(10, 1000)) .withMaxBatchSize(1000L)
Prevention
- Ensure stable network paths to Elasticsearch; truncated responses break entity parsing.
- Set explicit RetryConfiguration instead of relying on default error-code extraction.
- Keep batch sizes moderate so error responses stay small and fully readable.
When it happens
Trigger: An entity's getContent() stream throws IOException while scanning bulk items for findValue("status").asInt() == errorCode — typically a truncated or already-consumed response stream during retry evaluation.
Common situations: Connection reset while reading the bulk error response; response body drained by a previous attempt; proxy terminating the response early; very large error payloads cut off by timeouts.
Related errors
- Error matching file spec
- Error writing to ES after
- Failed to read broker response content
- 'items' missing from Elasticsearch response
- Unable to read file(s) after retrying
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/08de992bef818094.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java:1548
}
DefaultRetryPredicate() {
this(429);
}
/** Returns true if the response has the error code for any mutation. */
private static boolean errorCodePresent(HttpEntity responseEntity, int errorCode) {
try {
JsonNode json = parseResponse(responseEntity);
if (json.path("errors").asBoolean()) {
for (JsonNode item : json.path("items")) {
if (item.findValue("status").asInt() == errorCode) {
return true;
}
}
}
} catch (IOException e) {
LOG.warn("Could not extract error codes from responseEntity {}", responseEntity);
}
return false;
}
@Override
public boolean test(HttpEntity responseEntity) {
return errorCodePresent(responseEntity, errorCode);
}
}
}
/** A {@link PTransform} converting docs to their Bulk API counterparts. */
@AutoValue
public abstract static class DocToBulk
extends PTransform<PCollection<String>, PCollection<Document>> {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final int DEFAULT_RETRY_ON_CONFLICT = 5; // race conditions on updatesView on GitHub (pinned to 12126d8942)