{"record":{"id":"9c71874ebb43c240","repo":"apache/beam","slug":"the-batch-import-api-is-not-supported-yet","errorCode":null,"errorMessage":"The batch import API is not supported yet","messagePattern":"The batch import API is not supported yet","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java","lineNumber":950,"sourceCode":"        this.client = new HttpHealthcareApiClient();\n      }\n\n      /**\n       * Write messages.\n       *\n       * @param context the context\n       */\n      @ProcessElement\n      public void writeMessages(ProcessContext context) {\n        HL7v2Message msg = context.element();\n        // all fields but data and labels should be null for ingest.\n        Message model = new Message();\n        model.setData(msg.getData());\n        model.setLabels(msg.getLabels());\n        switch (writeMethod) {\n          case BATCH_IMPORT:\n            // TODO: add support for HL7v2 import.\n            throw new UnsupportedOperationException(\"The batch import API is not supported yet\");\n          case INGEST:\n          default:\n            try {\n              long requestTimestamp = Instant.now().getMillis();\n              client.ingestHL7v2Message(hl7v2Store.get(), model);\n              successfulHL7v2MessageWrites.inc();\n              messageIngestLatencyMs.update(Instant.now().getMillis() - requestTimestamp);\n            } catch (Exception e) {\n              failedMessageWrites.inc();\n              LOG.warn(\"Failed to ingest message\", e);\n              HealthcareIOError<HL7v2Message> err = HealthcareIOError.of(msg, e);\n              LOG.warn(\"{} {}\", err.getErrorMessage(), err.getStackTrace());\n              context.output(err);\n            }\n        }\n      }\n    }\n  }","sourceCodeStart":932,"sourceCodeEnd":968,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java#L932-L968","documentation":"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.","triggerScenarios":"Constructing HL7v2IO.Write.withMethod(HL7v2IO.WriteMethod.BATCH_IMPORT) and running the write transform; the first element written hits the switch case and throws immediately.","commonSituations":"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.","solutions":["Use HL7v2IO.WriteMethod.INGEST instead of BATCH_IMPORT until the feature is implemented.","If batch semantics are required, implement client-side batching of ingestHL7v2Message calls or call the batch import REST API yourself outside Beam.","Check the Beam version's release notes/issues for updated support before switching back."],"exampleFix":"// before\nHL7v2IO.Write write = HL7v2IO.write()\n    .withHL7v2Store(store)\n    .withMethod(HL7v2IO.WriteMethod.BATCH_IMPORT); // throws at runtime\n\n// after\nHL7v2IO.Write write = HL7v2IO.write()\n    .withHL7v2Store(store)\n    .withMethod(HL7v2IO.WriteMethod.INGEST);","handlingStrategy":"validation","validationCode":"if (writeMethod == HL7v2IO.WriteMethod.BATCH_IMPORT) {\n  throw new UnsupportedOperationException(\"Switch to WriteMethod.INGEST; BATCH_IMPORT is unsupported\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.apply(write.withMethod(method));\n} catch (UnsupportedOperationException e) {\n  LOG.error(\"Write method {} unsupported: {}\", method, e.getMessage());\n}","preventionTips":["Only use WriteMethod.INGEST until batch import is implemented.","Check Beam release notes/issues before adopting newer write methods.","Fail fast in configuration code, before launching the pipeline."],"tags":["java","apache-beam","google-cloud-healthcare","hl7v2","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}