{"record":{"id":"e020fab8d274e9c6","repo":"apache/beam","slug":"tupletag-tag-is-not-in-the-schema","errorCode":null,"errorMessage":"TupleTag ${tag} is not in the schema","messagePattern":"TupleTag (.+?) is not in the schema","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/join/CoGbkResult.java","lineNumber":216,"sourceCode":"    return schema;\n  }\n\n  @Override\n  public String toString() {\n    return valueMap.toString();\n  }\n\n  /**\n   * Returns the values from the table represented by the given {@code TupleTag<V>} as an {@code\n   * Iterable<V>} (which may be empty if there are no results).\n   *\n   * <p>If tag was not part of the original {@link CoGroupByKey}, throws an\n   * IllegalArgumentException.\n   */\n  public <V> Iterable<V> getAll(TupleTag<V> tag) {\n    int index = schema.getIndex(tag);\n    if (index < 0) {\n      throw new IllegalArgumentException(\"TupleTag \" + tag + \" is not in the schema\");\n    }\n    @SuppressWarnings(\"unchecked\")\n    Iterable<V> unions = (Iterable<V>) valueMap.get(index);\n    return unions;\n  }\n\n  /** Like {@link #getAll(TupleTag)} but using a String instead of a {@link TupleTag}. */\n  public <V> Iterable<V> getAll(String tag) {\n    return getAll(new TupleTag<>(tag));\n  }\n\n  /**\n   * If there is a singleton value for the given tag, returns it. Otherwise, throws an\n   * IllegalArgumentException.\n   *\n   * <p>If tag was not part of the original {@link CoGroupByKey}, throws an\n   * IllegalArgumentException.\n   */","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/join/CoGbkResult.java#L198-L234","documentation":"CoGbkResult.getAll(TupleTag) throws IllegalArgumentException when the requested tag was not part of the original CoGroupByKey schema. getIndex returns -1 for unknown tags, and Beam converts that into this explicit error so callers know they are asking for an output that this co-group never produced.","triggerScenarios":"Calling result.getAll(tag) with a TupleTag that was not registered in the CoGroupByKey transform's TaggedKeyedPCollectionTuple — e.g. a tag from a different co-group, a tag created fresh with the same id but different identity, or a typo'd tag.","commonSituations":"Refactoring pipelines so a tag is removed from the co-group but result consumers still reference it; constructing TupleTag literals inline (identity mismatch) instead of reusing the constants passed to CoGroupByKey; copying example code with different tags.","solutions":["Request a tag that was passed into the same CoGroupByKey call.","Reuse the same TupleTag constants (shared static finals) in both the co-group and getAll/getOnly calls.","Add the missing TupleTag to the CoGroupByKey input tuple if it should be present."],"exampleFix":"// before\nTupleTag<Integer> resultsTag = new TupleTag<>(); // fresh identity, not in schema\nresult.getAll(resultsTag);\n// after\nprivate static final TupleTag<Integer> RESULTS_TAG = new TupleTag<Integer>() {};\n// pass RESULTS_TAG to CoGroupByKey, then:\nresult.getAll(RESULTS_TAG);","handlingStrategy":"validation","validationCode":"// Confirm the tag exists before calling getAll:\nint idx = result.getSchema().getIndex(tag);\nif (idx < 0) { throw new IllegalArgumentException(\"Tag \" + tag + \" not in co-group\"); }","typeGuard":"<V> boolean tagInSchema(CoGbkResult r, TupleTag<V> tag) {\n  return r.getSchema().getIndex(tag) >= 0;\n}","tryCatchPattern":"try {\n  Iterable<V> vals = result.getAll(tag);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Use a TupleTag that was passed to CoGroupByKey\", e);\n}","preventionTips":["Define TupleTags as shared static final constants","Pass the identical tag instances to CoGroupByKey and result accessors","Never construct TupleTags inline at the point of getAll/getOnly"],"tags":["java","apache-beam","co-group","join","tuple-tag"],"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-14T16:17:12.679Z"}