apache/beam · error · RuntimeException

Export operation (%s) failed. Reason: %s

Error message

Export operation (%s) failed. Reason: %s

What it means

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.

Source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java:1735

          operation = client.exportFhirResourceToGcs(fhirStore, exportUri);
        } else if (exportUri.startsWith(BQ_PREFIX)) {
          operation = client.exportFhirResourceToBigQuery(fhirStore, exportUri);
        } else {
          throw new RuntimeException(
              String.format(
                  "Export cannot be executed because export URI (%s) is not from GCS or BigQuery.",
                  exportUri));
        }

        operation = client.pollOperation(operation, 15000L);
        incrementLroCounters(
            operation,
            EXPORT_OPERATION_SUCCESS,
            EXPORT_OPERATION_ERRORS,
            RESOURCES_EXPORTED_SUCCESS,
            RESOURCES_EXPORTED_ERRORS);
        if (operation.getError() != null) {
          throw new RuntimeException(
              String.format(
                  "Export operation (%s) failed. Reason: %s",
                  operation.getName(), operation.getError().getMessage()));
        }
        context.output(exportUri);
      }
    }
  }

  /** Deidentify FHIR resources from a FHIR store to a destination FHIR store. */
  public static class Deidentify extends PTransform<PBegin, PCollection<String>> {

    private final ValueProvider<String> sourceFhirStore;
    private final ValueProvider<String> destinationFhirStore;
    private final ValueProvider<DeidentifyConfig> deidConfig;

    public Deidentify(
        ValueProvider<String> sourceFhirStore,

View on GitHub (pinned to 12126d8942)

Solutions

  1. Read operation.getError().getMessage() in the exception message — fix the specific API-reported cause (usually IAM or destination config)
  2. Grant the Healthcare service agent write permission on the GCS bucket (roles/storage.objectCreator) or BQ dataset (roles/bigquery.dataEditor / jobUser)
  3. Verify the destination exists and its region matches the FHIR store region
  4. Re-run the export after correcting permissions; transient API issues can be retried

Example fix

// before
// export fails: service account cannot write to bucket
client.exportFhirResourceToGcs(fhirStore, "gs://other-project-bucket/export");
// after
// grant roles/storage.objectCreator on gs://other-project-bucket to the Healthcare service agent
client.exportFhirResourceToGcs(fhirStore, "gs://my-bucket/fhir-export");
Defensive patterns

Strategy: retry

Validate before calling

// pre-check destination writability
Storage storage = StorageOptions.getDefaultInstance().getService();
if (!storage.testIamPermissions(bucket, List.of("storage.objects.create"))) { /* fix IAM first */ }

Try / catch

try {
  // run export
} catch (RuntimeException e) {
  if (e.getMessage().startsWith("Export operation")) {
    // parse reason, fix IAM/destination, then retry with backoff
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/29de17b6a633c041. Report an issue: GitHub.