{"record":{"id":"eb62bc1bd73c0d7d","repo":"apache/beam","slug":"tupletag-s-not-found-in-this-pcollectiontuple-tuple","errorCode":null,"errorMessage":"TupleTag %s not found in this PCollectionTuple tuple","messagePattern":"TupleTag (.+?) not found in this PCollectionTuple tuple","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionTuple.java","lineNumber":221,"sourceCode":"\n  /**\n   * Returns whether this {@link PCollectionTuple} contains a {@link PCollection} with the given\n   * tag.\n   */\n  public <T> boolean has(String tag) {\n    return has(new TupleTag<>(tag));\n  }\n\n  /**\n   * Returns the {@link PCollection} associated with the given {@link TupleTag} in this {@link\n   * PCollectionTuple}. Throws {@link IllegalArgumentException} if there is no such {@link\n   * PCollection}, i.e., {@code !has(tag)}.\n   */\n  public <T> PCollection<T> get(TupleTag<T> tag) {\n    @SuppressWarnings(\"unchecked\")\n    PCollection<T> pcollection = (PCollection<T>) pcollectionMap.get(tag);\n    if (pcollection == null) {\n      throw new IllegalArgumentException(\n          String.format(\"TupleTag %s not found in this PCollectionTuple tuple\", tag));\n    }\n    return pcollection;\n  }\n\n  /**\n   * Returns the {@link PCollection} associated with the given tag in this {@link PCollectionTuple}.\n   * Throws {@link IllegalArgumentException} if there is no such {@link PCollection}, i.e., {@code\n   * !has(tag)}.\n   */\n  public <T> PCollection<T> get(String tag) {\n    return get(new TupleTag<>(tag));\n  }\n\n  /**\n   * Returns an immutable Map from {@link TupleTag} to corresponding {@link PCollection}, for all\n   * the members of this {@link PCollectionTuple}.\n   */","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionTuple.java#L203-L239","documentation":"PCollectionTuple.get(TupleTag) throws IllegalArgumentException when the given TupleTag is not a key in the tuple's map. Beam fails fast instead of returning null, formatting the missing tag into the message.","triggerScenarios":"Calling get(tag) with a TupleTag that was never added via and() or produced by the source transform; using a new TupleTag<>(\"name\") instance that differs from the one registered if tags lack proper identity semantics.","commonSituations":"Mismatch between output TupleTags declared in a DoFn/transform and the tags queried in the test or downstream code; constructing an equal-looking TupleTag instead of reusing the constant.","solutions":["Check tuple.has(tag) before calling get(tag)","Reuse the same TupleTag constant used when the output was added, rather than creating a new instance","Confirm the transform's output tag names (via getTupleTags or docs) match the queried tag"],"exampleFix":"// before\nTupleTag<String> out = new TupleTag<>(\"fails\");\nPCollection<String> pc = tuple.get(out); // throws if registered tag differs\n// after\nTupleTag<String> out = MY_TRANSFORM.FAILURES_TAG; // shared constant\nif (tuple.has(out)) {\n  PCollection<String> pc = tuple.get(out);\n}","handlingStrategy":"validation","validationCode":"if (!tuple.has(tag)) { throw new IllegalArgumentException(\"missing TupleTag: \" + tag); }","typeGuard":"boolean hasTag(PCollectionTuple t, TupleTag<?> tag) { return t.has(tag); }","tryCatchPattern":"try { return tuple.get(tag); } catch (IllegalArgumentException e) { return tuple.get(knownTagConstant); }","preventionTips":["Reuse TupleTag constants instead of constructing new instances","Call has(tag) before get(tag)","Keep TupleTag declarations next to the transform that emits them"],"tags":["java","apache-beam","illegal-argument","tag-lookup"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}