apache/beam · error
execute bundles entry contains bad status
Error message
execute bundles entry contains bad status: [%v]
What it means
Within each entry of an executeBundle response, fhirio inspects entry.response.status (an HTTP-style status string like '200' or '404'). If batchResponseStatusIsBad reports the status as failed, it emits a per-entry failure with this message rather than a wrapped error — the string is generated with errors.Errorf, not wrapping a cause.
Solutions
- Read the status value printed in the [%v] placeholder to identify the failing entry's HTTP code
- Log the full entry JSON (it is available in entryBytes) to find the OperationOutcome details
- Fix the offending entry's resource payload per the FHIR OperationOutcome diagnostics
- Split large bundles so one bad entry does not obscure others; re-run only failures
- Check FHIR store configuration (e.g. enforced referential integrity, required fields)
- Enable create/update defaults to resolve 400/422 constraint errors
Example fix
// before (all-or-nothing batch, hard to find the bad entry)
// after: inspect per-entry status and log details
for _, entry := range bodyFields.Entries {
if batchResponseStatusIsBad(entry.Response.Status) {
log.Debugf(ctx, "bad entry: %s", string(entryBytes))
}
} Defensive patterns
Strategy: validation
Validate before calling
// validate resources against FHIR profile before bundling
for _, r := range resources {
if err := validateAgainstProfile(r); err != nil {
return fmt.Errorf("resource %s fails validation: %w", r.ID, err)
}
} Prevention
- Validate each bundle entry payload against the FHIR spec/profile up front
- Confirm referenced resource IDs exist before writing
- Split big transactions so failures are isolated per entry
- Capture and store entryBytes from emitFailure for post-run diagnosis
When it happens
Trigger: Any bundle entry whose response.status parses as a bad HTTP status (>= 400 or unparseable), e.g. a failed create/update/delete within the transaction batch.
Common situations: Bundle entries referencing resources that violate FHIR constraints (422), referencing nonexistent resources (404), schema mismatches on update (400), or concurrent-modification conflicts on writes.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- error occurred while performing search for query
- could not extract body from execute bundles response
- could not extract body from read resource
- could not parse body from execute bundle response
- could not resolve to a temp directory for import batch files
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/9643be86b530b99e.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/fhirio/execute_bundles.go:119
case bundleResponseTypeTransaction:
fn.resourcesSuccessCount.Inc(ctx, int64(len(bodyFields.Entries)))
emitSuccess(body)
case bundleResponseTypeBatch:
for _, entry := range bodyFields.Entries {
var entryFields struct {
Response struct {
Status string `json:"status"`
} `json:"response"`
}
entryBytes, _ := json.Marshal(entry)
_ = json.NewDecoder(bytes.NewReader(entryBytes)).Decode(&entryFields)
if entryFields.Response.Status == "" {
continue
}
if batchResponseStatusIsBad(entryFields.Response.Status) {
fn.resourcesErrorCount.Inc(ctx, 1)
emitFailure(errors.Errorf("execute bundles entry contains bad status: [%v]", entryFields.Response.Status).Error())
} else {
fn.resourcesSuccessCount.Inc(ctx, 1)
emitSuccess(string(entryBytes))
}
}
}
fn.successesCount.Inc(ctx, 1)
}
func batchResponseStatusIsBad(status string) bool {
// 2XXs are successes, otherwise failure.
isMatch, err := regexp.MatchString("^2\\d{2}", status)
if err != nil {
return true
}
return !isMatch
}View on GitHub (pinned to 12126d8942)