{"record":{"id":"620b3260931abb6e","repo":"apache/beam","slug":"could-not-extract-body-from-execute-bundles-response","errorCode":null,"errorMessage":"could not extract body from execute bundles response","messagePattern":"could not extract body from execute bundles response","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/fhirio/execute_bundles.go","lineNumber":72,"sourceCode":"func (fn *executeBundleFn) Setup() {\n\tfn.fnCommonVariables.setup(fn.String())\n\tfn.successesCount = beam.NewCounter(fn.String(), baseMetricPrefix+\"success_count\")\n}\n\nfunc (fn *executeBundleFn) ProcessElement(ctx context.Context, inputBundleBody string, emitSuccess, emitFailure func(string)) {\n\tresponse, err := executeAndRecordLatency(ctx, &fn.latencyMs, func() (*http.Response, error) {\n\t\treturn fn.client.executeBundle(fn.FhirStorePath, inputBundleBody)\n\t})\n\tif err != nil {\n\t\tfn.resourcesErrorCount.Inc(ctx, 1)\n\t\temitFailure(errors.Wrap(err, \"execute bundle request returned error\").Error())\n\t\treturn\n\t}\n\n\tbody, err := extractBodyFrom(response)\n\tif err != nil {\n\t\tfn.resourcesErrorCount.Inc(ctx, 1)\n\t\temitFailure(errors.Wrap(err, \"could not extract body from execute bundles response\").Error())\n\t\treturn\n\t}\n\n\tfn.processResponseBody(ctx, body, emitSuccess, emitFailure)\n}\n\nfunc (fn *executeBundleFn) processResponseBody(ctx context.Context, body string, emitSuccess, emitFailure func(string)) {\n\tvar bodyFields struct {\n\t\tType    string `json:\"type\"`\n\t\tEntries []any  `json:\"entry\"`\n\t}\n\n\terr := json.NewDecoder(strings.NewReader(body)).Decode(&bodyFields)\n\tif err != nil {\n\t\tfn.resourcesErrorCount.Inc(ctx, 1)\n\t\temitFailure(errors.Wrap(err, \"could not parse body from execute bundle response\").Error())\n\t\treturn\n\t}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/fhirio/execute_bundles.go#L54-L90","documentation":"After a successful executeBundle HTTP response, fhirio calls extractBodyFrom to read and decode the response body. If reading the body (or validating the HTTP status inside extractBodyFrom) fails, the bundle's outcome cannot be determined, so the error is wrapped with this message and emitted to the failure channel.","triggerScenarios":"extractBodyFrom(response) returns an error on the executeBundle response: the response body read fails (connection reset mid-body) or the HTTP status is not 2xx so the body cannot be treated as a success payload.","commonSituations":"FHIR server closing the connection while the body is streaming; proxies/load balancers returning error pages with non-200 status; truncated responses on large batch bundles over unstable networks (e.g. Dataflow workers with flaky egress).","solutions":["Log the full response (status + headers) at the HTTP client level to identify the failing status code","Inspect the emitted failure string for the wrapped extractBodyFrom cause (e.g. non-2xx status)","Retry the bundle — executeBundle is idempotent for most FHIR transaction bundles","Check for intermediaries (proxy, WAF) that terminate streaming bodies","Reduce bundle size to avoid timeouts/truncation on very large batches"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// treat failures from emitFailure as retryable\nfailures := beam.ParDo(s, &collectFailures{}, bundleResults)\nbeam.ParDo(s, &retryWithBackoff{MaxAttempts: 3}, failures)","preventionTips":["Keep executeBundle requests under server/proxy timeout limits","Avoid intermediaries that break streaming responses","Log HTTP status and response headers client-side for diagnosis","Retry GET-like/idempotent bundles automatically"],"tags":["go","fhirio","http-response"],"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"}