{"record":{"id":"cd99faa8800e1e5f","repo":"apache/beam","slug":"tag-not-found-in-this-pcollectionrowtuple-tuple","errorCode":null,"errorMessage":"Tag not found in this PCollectionRowTuple tuple","messagePattern":"Tag not found in this PCollectionRowTuple tuple","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionRowTuple.java","lineNumber":179,"sourceCode":"\n  /**\n   * Returns whether this {@link PCollectionRowTuple} contains a {@link PCollection} with the given\n   * tag.\n   */\n  public boolean has(String tag) {\n    return pcollectionMap.containsKey(tag);\n  }\n\n  /**\n   * Returns the {@link PCollection} associated with the given {@link String} in this {@link\n   * PCollectionRowTuple}. Throws {@link IllegalArgumentException} if there is no such {@link\n   * PCollection}, i.e., {@code !has(tag)}.\n   */\n  public PCollection<Row> get(String tag) {\n    @SuppressWarnings(\"unchecked\")\n    PCollection<Row> pcollection = pcollectionMap.get(tag);\n    if (pcollection == null) {\n      throw new IllegalArgumentException(\"Tag not found in this PCollectionRowTuple tuple\");\n    }\n    return pcollection;\n  }\n\n  /**\n   * Like {@link #get(String)}, but is a convenience method to get a single PCollection without\n   * providing a tag for that output. Use only when there is a single collection in this tuple.\n   *\n   * <p>Throws {@link IllegalStateException} if more than one output exists in the {@link\n   * PCollectionRowTuple}.\n   */\n  public PCollection<Row> getSinglePCollection() {\n    Preconditions.checkState(\n        pcollectionMap.size() == 1,\n        \"Expected exactly one output PCollection<Row>, but found %s. \"\n            + \"Please try retrieving a specified output using get(<tag>) instead.\",\n        pcollectionMap.size());\n    return get(pcollectionMap.entrySet().iterator().next().getKey());","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionRowTuple.java#L161-L197","documentation":"PCollectionRowTuple.get(tag) found no entry for the requested tag in its tag-to-PCollection map — pcollectionMap.get returned null. The tag string is the faulty input: it was never added via of(...)/and(...), i.e. has(tag) is false, matching the documented contract that get throws for unknown tags.","triggerScenarios":"Calling get(tag) with a tag never added via and()/of(), or with a tag whose spelling/case differs from the key used when adding.","commonSituations":"Typos in output tag strings; renaming a tag in the writer but not the reader; reading a tuple output produced by a transform with different tag names.","solutions":["Check tuple.has(tag) before calling get(tag)","Verify the tag string matches the one used in and() or the transform's output tags exactly","List known tags (e.g. log the map keys) to confirm the correct tag name"],"exampleFix":"// before\nPCollection<Row> pc = tuple.get(\"Counts\"); // throws if tag is \"counts\"\n// after\nPCollection<Row> pc = tuple.has(\"counts\")\n    ? tuple.get(\"counts\")\n    : fallbackPCollection;","handlingStrategy":"validation","validationCode":"if (!tuple.has(tag)) { throw new IllegalArgumentException(\"missing tag: \" + tag); }","typeGuard":"boolean hasTag(PCollectionRowTuple t, String tag) { return t.has(tag); }","tryCatchPattern":"try { return tuple.get(tag); } catch (IllegalArgumentException e) { return null; /* or default */ }","preventionTips":["Define tag names as constants shared by writer and reader","Call has(tag) before get(tag)","Log available tag keys when a lookup fails"],"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"}