apache/beam · error · IllegalArgumentException

The PCollection tuple bodies must have the FhirIO.Write.SUCC

Error message

The PCollection tuple bodies must have the FhirIO.Write.SUCCESSFUL_BODY and FhirIO.Write.FAILED_BODY tuple tags.

What it means

FhirIO.Write.Result.in(pipeline, bodies) validates that the PCollectionTuple of request bodies contains both the FhirIO.Write.SUCCESSFUL_BODY and FhirIO.Write.FAILED_BODY TupleTags. The Write transform partitions input bodies into successful and failed streams, so without both tags the Result cannot wire up its outputs and an IllegalArgumentException is thrown. This is a fail-fast check at pipeline-construction time.

Source

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

    public static class Result extends AbstractResult {

      private final Pipeline pipeline;
      private final PCollection<String> successfulBodies;
      private final PCollection<HealthcareIOError<String>> failedBodies;
      private final PCollection<HealthcareIOError<String>> failedFiles;

      /**
       * Creates a {@link FhirIO.Write.Result} in the given {@link Pipeline}.
       *
       * @param pipeline the pipeline
       * @param bodies the successful and failing bodies results.
       * @return the result
       */
      static Result in(Pipeline pipeline, PCollectionTuple bodies) throws IllegalArgumentException {
        if (bodies.has(SUCCESSFUL_BODY) && bodies.has(FAILED_BODY)) {
          return new Result(pipeline, bodies.get(SUCCESSFUL_BODY), bodies.get(FAILED_BODY), null);
        } else {
          throw new IllegalArgumentException(
              "The PCollection tuple bodies must have the FhirIO.Write.SUCCESSFUL_BODY "
                  + "and FhirIO.Write.FAILED_BODY tuple tags.");
        }
      }

      static Result in(
          Pipeline pipeline,
          PCollection<HealthcareIOError<String>> failedBodies,
          PCollection<HealthcareIOError<String>> failedFiles) {
        return new Result(pipeline, null, failedBodies, failedFiles);
      }

      /**
       * Gets successful bodies from Write.
       *
       * @return the entries that were inserted
       */
      @Override

View on GitHub (pinned to 12126d8942)

Solutions

  1. Populate the tuple with both tags: bodies.apply(FhirIO.Write.SUCCESSFUL_BODY, okBodies) and bodies.apply(FhirIO.Write.FAILED_BODY, failedBodies)
  2. Use the constant TupleTags FhirIO.Write.SUCCESSFUL_BODY / FhirIO.Write.FAILED_BODY, not newly instantiated TupleTags with similar names
  3. Check the two-argument Result.in overload or use the write transform's own Result return value
  4. Guard with bodies.has(SUCCESSFUL_BODY) && bodies.has(FAILED_BODY) in development builds

Example fix

// before
PCollectionTuple bodies = PCollectionTuple.of(FhirIO.Write.SUCCESSFUL_BODY, ok);
FhirIO.Write.Result r = FhirIO.Write.Result.in(pipeline, bodies); // throws
// after
bodies.put(FhirIO.Write.FAILED_BODY, failed);
FhirIO.Write.Result r = FhirIO.Write.Result.in(pipeline, bodies);
Defensive patterns

Strategy: validation

Validate before calling

if (bodies.has(FhirIO.Write.SUCCESSFUL_BODY) && bodies.has(FhirIO.Write.FAILED_BODY)) {
  FhirIO.Write.Result r = FhirIO.Write.Result.in(pipeline, bodies);
}

Try / catch

try {
  FhirIO.Write.Result r = FhirIO.Write.Result.in(pipeline, bodies);
} catch (IllegalArgumentException e) {
  LOG.error("Tuple missing SUCCESSFUL_BODY/FAILED_BODY tags", e);
}

Prevention

When it happens

Trigger: Calling FhirIO.Write.Result.in() with a PCollectionTuple missing SUCCESSFUL_BODY or FAILED_BODY — typically a tuple built manually or reusing a Write result's tags incorrectly.

Common situations: Hand-assembling the PCollectionTuple instead of using the output of a prior FhirIO.Write result; only needing the success stream and omitting the failed-body tag; refactoring that renamed tags.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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