{"record":{"id":"9643be86b530b99e","repo":"apache/beam","slug":"execute-bundles-entry-contains-bad-status-v","errorCode":null,"errorMessage":"execute bundles entry contains bad status: [%v]","messagePattern":"execute bundles entry contains bad status: \\[(.+?)\\]","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/fhirio/execute_bundles.go","lineNumber":119,"sourceCode":"\tcase bundleResponseTypeTransaction:\n\t\tfn.resourcesSuccessCount.Inc(ctx, int64(len(bodyFields.Entries)))\n\t\temitSuccess(body)\n\tcase bundleResponseTypeBatch:\n\t\tfor _, entry := range bodyFields.Entries {\n\t\t\tvar entryFields struct {\n\t\t\t\tResponse struct {\n\t\t\t\t\tStatus string `json:\"status\"`\n\t\t\t\t} `json:\"response\"`\n\t\t\t}\n\t\t\tentryBytes, _ := json.Marshal(entry)\n\t\t\t_ = json.NewDecoder(bytes.NewReader(entryBytes)).Decode(&entryFields)\n\t\t\tif entryFields.Response.Status == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif batchResponseStatusIsBad(entryFields.Response.Status) {\n\t\t\t\tfn.resourcesErrorCount.Inc(ctx, 1)\n\t\t\t\temitFailure(errors.Errorf(\"execute bundles entry contains bad status: [%v]\", entryFields.Response.Status).Error())\n\t\t\t} else {\n\t\t\t\tfn.resourcesSuccessCount.Inc(ctx, 1)\n\t\t\t\temitSuccess(string(entryBytes))\n\t\t\t}\n\t\t}\n\t}\n\n\tfn.successesCount.Inc(ctx, 1)\n}\n\nfunc batchResponseStatusIsBad(status string) bool {\n\t// 2XXs are successes, otherwise failure.\n\tisMatch, err := regexp.MatchString(\"^2\\\\d{2}\", status)\n\tif err != nil {\n\t\treturn true\n\t}\n\treturn !isMatch\n}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/fhirio/execute_bundles.go#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"Bundle entries referencing resources that violate FHIR constraints (422), referencing nonexistent resources (404), schema mismatches on update (400), or concurrent-modification conflicts on writes.","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"],"exampleFix":"// before (all-or-nothing batch, hard to find the bad entry)\n// after: inspect per-entry status and log details\nfor _, entry := range bodyFields.Entries {\n    if batchResponseStatusIsBad(entry.Response.Status) {\n        log.Debugf(ctx, \"bad entry: %s\", string(entryBytes))\n    }\n}","handlingStrategy":"validation","validationCode":"// validate resources against FHIR profile before bundling\nfor _, r := range resources {\n    if err := validateAgainstProfile(r); err != nil {\n        return fmt.Errorf(\"resource %s fails validation: %w\", r.ID, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["go","fhirio","fhir","batch-status"],"backgroundTag":"http-error-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}