{"record":{"id":"29de17b6a633c041","repo":"apache/beam","slug":"export-operation-s-failed-reason-s","errorCode":null,"errorMessage":"Export operation (%s) failed. Reason: %s","messagePattern":"Export operation \\((.+?)\\) failed\\. Reason: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java","lineNumber":1735,"sourceCode":"          operation = client.exportFhirResourceToGcs(fhirStore, exportUri);\n        } else if (exportUri.startsWith(BQ_PREFIX)) {\n          operation = client.exportFhirResourceToBigQuery(fhirStore, exportUri);\n        } else {\n          throw new RuntimeException(\n              String.format(\n                  \"Export cannot be executed because export URI (%s) is not from GCS or BigQuery.\",\n                  exportUri));\n        }\n\n        operation = client.pollOperation(operation, 15000L);\n        incrementLroCounters(\n            operation,\n            EXPORT_OPERATION_SUCCESS,\n            EXPORT_OPERATION_ERRORS,\n            RESOURCES_EXPORTED_SUCCESS,\n            RESOURCES_EXPORTED_ERRORS);\n        if (operation.getError() != null) {\n          throw new RuntimeException(\n              String.format(\n                  \"Export operation (%s) failed. Reason: %s\",\n                  operation.getName(), operation.getError().getMessage()));\n        }\n        context.output(exportUri);\n      }\n    }\n  }\n\n  /** Deidentify FHIR resources from a FHIR store to a destination FHIR store. */\n  public static class Deidentify extends PTransform<PBegin, PCollection<String>> {\n\n    private final ValueProvider<String> sourceFhirStore;\n    private final ValueProvider<String> destinationFhirStore;\n    private final ValueProvider<DeidentifyConfig> deidConfig;\n\n    public Deidentify(\n        ValueProvider<String> sourceFhirStore,","sourceCodeStart":1717,"sourceCodeEnd":1753,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java#L1717-L1753","documentation":"After launching the FHIR store export, FhirIO polls the long-running operation via client.pollOperation. When the completed operation carries a non-null error, the export failed server-side, and a RuntimeException is thrown embedding the operation name and the API-supplied error message. This surfaces Healthcare API-side failures (permissions, bad destination, quota) to the pipeline rather than silently emitting the export URI.","triggerScenarios":"Polling an export operation that finished with error status — e.g. the service account lacks write access to the GCS bucket/BQ dataset, the destination doesn't exist, or the FHIR store is in a failed state.","commonSituations":"Destination bucket in a different project without cross-project permissions; BigQuery dataset missing or dataset region incompatible; Healthcare API outage or quota exhaustion; malformed destination path accepted by the client but rejected during execution.","solutions":["Read operation.getError().getMessage() in the exception message — fix the specific API-reported cause (usually IAM or destination config)","Grant the Healthcare service agent write permission on the GCS bucket (roles/storage.objectCreator) or BQ dataset (roles/bigquery.dataEditor / jobUser)","Verify the destination exists and its region matches the FHIR store region","Re-run the export after correcting permissions; transient API issues can be retried"],"exampleFix":"// before\n// export fails: service account cannot write to bucket\nclient.exportFhirResourceToGcs(fhirStore, \"gs://other-project-bucket/export\");\n// after\n// grant roles/storage.objectCreator on gs://other-project-bucket to the Healthcare service agent\nclient.exportFhirResourceToGcs(fhirStore, \"gs://my-bucket/fhir-export\");","handlingStrategy":"retry","validationCode":"// pre-check destination writability\nStorage storage = StorageOptions.getDefaultInstance().getService();\nif (!storage.testIamPermissions(bucket, List.of(\"storage.objects.create\"))) { /* fix IAM first */ }","typeGuard":null,"tryCatchPattern":"try {\n  // run export\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Export operation\")) {\n    // parse reason, fix IAM/destination, then retry with backoff\n  } else throw e;\n}","preventionTips":["Grant the Healthcare service agent objectCreator on the export bucket or BQ editor on the dataset","Verify destination exists and region-matches the FHIR store","Set up GCS/BQ destination before launching the pipeline"],"tags":["java","fhir","export","gcp-api","permissions"],"backgroundTag":"api-error-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}