apache/beam · error · UnsupportedOperationException

The batch import API is not supported yet

Error message

The batch import API is not supported yet

What it means

HL7v2IO.Write with writeMethod=BATCH_IMPORT is explicitly unimplemented: the switch in the write path throws UnsupportedOperationException with this message, leaving only the INGEST method working. The library authors left a TODO to add HL7v2 batch-import support.

Source

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

        this.client = new HttpHealthcareApiClient();
      }

      /**
       * Write messages.
       *
       * @param context the context
       */
      @ProcessElement
      public void writeMessages(ProcessContext context) {
        HL7v2Message msg = context.element();
        // all fields but data and labels should be null for ingest.
        Message model = new Message();
        model.setData(msg.getData());
        model.setLabels(msg.getLabels());
        switch (writeMethod) {
          case BATCH_IMPORT:
            // TODO: add support for HL7v2 import.
            throw new UnsupportedOperationException("The batch import API is not supported yet");
          case INGEST:
          default:
            try {
              long requestTimestamp = Instant.now().getMillis();
              client.ingestHL7v2Message(hl7v2Store.get(), model);
              successfulHL7v2MessageWrites.inc();
              messageIngestLatencyMs.update(Instant.now().getMillis() - requestTimestamp);
            } catch (Exception e) {
              failedMessageWrites.inc();
              LOG.warn("Failed to ingest message", e);
              HealthcareIOError<HL7v2Message> err = HealthcareIOError.of(msg, e);
              LOG.warn("{} {}", err.getErrorMessage(), err.getStackTrace());
              context.output(err);
            }
        }
      }
    }
  }

View on GitHub (pinned to 12126d8942)

Solutions

  1. Use HL7v2IO.WriteMethod.INGEST instead of BATCH_IMPORT until the feature is implemented.
  2. If batch semantics are required, implement client-side batching of ingestHL7v2Message calls or call the batch import REST API yourself outside Beam.
  3. Check the Beam version's release notes/issues for updated support before switching back.

Example fix

// before
HL7v2IO.Write write = HL7v2IO.write()
    .withHL7v2Store(store)
    .withMethod(HL7v2IO.WriteMethod.BATCH_IMPORT); // throws at runtime

// after
HL7v2IO.Write write = HL7v2IO.write()
    .withHL7v2Store(store)
    .withMethod(HL7v2IO.WriteMethod.INGEST);
Defensive patterns

Strategy: validation

Validate before calling

if (writeMethod == HL7v2IO.WriteMethod.BATCH_IMPORT) {
  throw new UnsupportedOperationException("Switch to WriteMethod.INGEST; BATCH_IMPORT is unsupported");
}

Try / catch

try {
  pipeline.apply(write.withMethod(method));
} catch (UnsupportedOperationException e) {
  LOG.error("Write method {} unsupported: {}", method, e.getMessage());
}

Prevention

When it happens

Trigger: Constructing HL7v2IO.Write.withMethod(HL7v2IO.WriteMethod.BATCH_IMPORT) and running the write transform; the first element written hits the switch case and throws immediately.

Common situations: Developers choosing BATCH_IMPORT assuming parity with the REST API's hl7V2Stores.messages.import capability; migrating code between Beam versions and copying a method enum value without checking support.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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