{"record":{"id":"7a5da9c5e57aad51","repo":"apache/beam","slug":"the-pcollection-tuple-must-have-the-hl7v2io-hl7v2read-out","errorCode":null,"errorMessage":"The PCollection tuple must have the HL7v2IO.HL7v2Read.OUT and HL7v2IO.HL7v2Read.DEAD_LETTER tuple tags","messagePattern":"The PCollection tuple must have the HL7v2IO\\.HL7v2Read\\.OUT and HL7v2IO\\.HL7v2Read\\.DEAD_LETTER tuple tags","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java","lineNumber":405,"sourceCode":"  public static class HL7v2Read\n      extends PTransform<PCollection<HL7v2ReadParameter>, HL7v2Read.Result> {\n\n    public HL7v2Read() {}\n\n    /**\n     * The type Result includes {@link PCollection} of {@link HL7v2ReadResponse} objects for\n     * successfully read results and {@link PCollection} of {@link HealthcareIOError} objects for\n     * failed reads.\n     */\n    public static class Result extends HL7v2ReadResult<HL7v2ReadParameter, HL7v2ReadResponse> {\n\n      public static Result of(PCollectionTuple pct) throws IllegalArgumentException {\n        if (pct.getAll()\n            .keySet()\n            .containsAll(TupleTagList.of(HL7v2Read.OUT).and(HL7v2Read.DEAD_LETTER).getAll())) {\n          return new HL7v2Read.Result(pct);\n        } else {\n          throw new IllegalArgumentException(\n              \"The PCollection tuple must have the HL7v2IO.HL7v2Read.OUT \"\n                  + \"and HL7v2IO.HL7v2Read.DEAD_LETTER tuple tags\");\n        }\n      }\n\n      private Result(PCollectionTuple pct) {\n        super(pct);\n        this.out = HL7v2Read.OUT;\n        this.messages = pct.get(OUT).setCoder(HL7v2ReadResponseCoder.of());\n        this.failedReads =\n            pct.get(DEAD_LETTER)\n                .setCoder(\n                    HealthcareIOErrorCoder.of(SerializableCoder.of(HL7v2ReadParameter.class)));\n      }\n    }\n\n    /** The tag for the main output of HL7v2 read responses. */\n    public static final TupleTag<HL7v2ReadResponse> OUT = new TupleTag<HL7v2ReadResponse>() {};","sourceCodeStart":387,"sourceCodeEnd":423,"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#L387-L423","documentation":"HL7v2IO.HL7v2Read.Result.of() validates that the supplied PCollectionTuple contains PCollections under the HL7v2IO.HL7v2Read.OUT and HL7v2IO.HL7v2Read.DEAD_LETTER tuple tags. This is a distinct variant from HL7v2IO.Read (error 1961): HL7v2Read is the legacy/alternate read representation, and its Result refuses tuples that don't carry both of its own tags.","triggerScenarios":"Calling HL7v2IO.HL7v2Read.Result.of(pct) with a tuple built for a different transform (e.g. one using HL7v2IO.Read's tags), or a tuple missing either the OUT or DEAD_LETTER PCollection.","commonSituations":"Mixing tags between HL7v2IO.Read and HL7v2IO.HL7v2Read after refactoring between the two APIs; only registering the successful-read PCollection; constructing the PCollectionTuple manually with ad-hoc TupleTags.","solutions":["Ensure both PCollections are registered with HL7v2IO.HL7v2Read.OUT and HL7v2IO.HL7v2Read.DEAD_LETTER TupleTags.","Verify you are not passing a tuple whose tags belong to HL7v2IO.Read; each Result class requires its own transform's tags.","Derive the PCollectionTuple from the HL7v2Read transform's output rather than assembling it by hand."],"exampleFix":"// before\nPCollectionTuple pct = PCollectionTuple.of(HL7v2IO.Read.OUT, msgs, HL7v2IO.Read.DEAD_LETTER, fails);\nHL7v2IO.HL7v2Read.Result.of(pct); // throws: wrong tags\n\n// after\nPCollectionTuple pct = PCollectionTuple.of(HL7v2IO.HL7v2Read.OUT, msgs,\n    HL7v2IO.HL7v2Read.DEAD_LETTER, fails);\nHL7v2IO.HL7v2Read.Result.of(pct);","handlingStrategy":"validation","validationCode":"if (!pct.getAll().keySet().containsAll(TupleTagList.of(HL7v2IO.HL7v2Read.OUT).and(HL7v2IO.HL7v2Read.DEAD_LETTER).getAll())) {\n  throw new IllegalArgumentException(\"HL7v2IO.HL7v2Read tuple missing OUT or DEAD_LETTER\");\n}","typeGuard":"boolean isHl7v2ReadVariantResult(PCollectionTuple pct) {\n  return pct.getAll().keySet().containsAll(\n      TupleTagList.of(HL7v2IO.HL7v2Read.OUT).and(HL7v2IO.HL7v2Read.DEAD_LETTER).getAll());\n}","tryCatchPattern":"try {\n  HL7v2IO.HL7v2Read.Result r = HL7v2IO.HL7v2Read.Result.of(pct);\n} catch (IllegalArgumentException e) {\n  throw new IllegalStateException(\"Wrong PCollectionTuple tags for HL7v2Read.Result\", e);\n}","preventionTips":["Match the Result class to the transform: HL7v2Read.Result only accepts HL7v2Read's own tags.","After refactoring between Read and HL7v2Read, update tuple tag references too.","Prefer deriving the tuple from the transform output."],"tags":["java","apache-beam","google-cloud-healthcare","hl7v2","illegal-argument"],"backgroundTag":"missing-required-argument","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"}