{"record":{"id":"9b9a6ee0b004f638","repo":"apache/beam","slug":"unexpected-kind-kind","errorCode":null,"errorMessage":"Unexpected kind: ${kind}","messagePattern":"Unexpected kind: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/Group.java","lineNumber":1285,"sourceCode":"        Field outputField) {\n      return toBuilder()\n          .setSchemaAggregateFn(\n              getSchemaAggregateFn().aggregateFields(fieldsToAggregate, false, fn, outputField))\n          .build();\n    }\n\n    PTransform<PCollection<KV<Row, Row>>, PCollection<KV<Row, Row>>> getCombineTransform(\n        Schema schema) {\n      SchemaAggregateFn.Inner fn = getSchemaAggregateFn().withSchema(schema);\n      @Nullable Fanout fanout = getFanout();\n      if (fanout != null) {\n        switch (fanout.getKind()) {\n          case NUMBER:\n            return Combine.<Row, Row, Row>perKey(fn).withHotKeyFanout(fanout.getNumber());\n          case FUNCTION:\n            return Combine.<Row, Row, Row>perKey(fn).withHotKeyFanout(fanout.getFunction());\n          default:\n            throw new RuntimeException(\"Unexpected kind: \" + fanout.getKind());\n        }\n      }\n      return getFewKeys() ? Combine.fewKeys(fn) : Combine.perKey(fn);\n    }\n\n    @Override\n    public PCollection<Row> expand(PCollection<InputT> input) {\n\n      Schema keySchema = getByFields().getKeySchema(input.getSchema());\n      Schema outputSchema =\n          Schema.builder()\n              .addRowField(getKeyField(), keySchema)\n              .addRowField(getValueField(), getSchemaAggregateFn().getOutputSchema())\n              .build();\n\n      return input\n          .apply(\"ToKvs\", getByFields().getToKV())\n          .apply(\"Combine\", getCombineTransform(input.getSchema()))","sourceCodeStart":1267,"sourceCodeEnd":1303,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/Group.java#L1267-L1303","documentation":"Group.toCombine (hot key fanout handling) supports only NUMBER and FUNCTION kinds for the per-key fanout. Any other HotKeyFanout kind hits the default branch and throws, indicating an unrecognized enumeration value.","triggerScenarios":"Calling withHotKeyFanout with a value whose getKind() is neither NUMBER nor FUNCTION — practically this arises when a serialized/constructed fanout carries an unexpected kind enum, e.g. via custom Row encoding of Combine.PerKey options.","commonSituations":"Rare; typically encountered when programmatically building Group.byFieldNames(...).combining per-key options or after serialization corruption / version mismatch of pipeline options encoding the fanout kind.","solutions":["Use only withHotKeyFanout(int) or withHotKeyFanout(SerializableFunction) variants.","If building programmatically, ensure the fanout object's kind matches one of the two supported cases.","Check Beam version consistency between pipeline construction and runner; a mismatched enum decoding can cause this.","If hit with standard API usage, report a Beam bug with a reproducing pipeline."],"exampleFix":"// before\nfanout of unrecognized kind passed into Group.combine\n// after\n.apply(Group.byFieldNames(\"key\").combineFields(fn).withHotKeyFanout(2))","handlingStrategy":"validation","validationCode":"if (fanout.getKind() != NUMBER && fanout.getKind() != FUNCTION) throw new IllegalArgumentException(\"Unsupported hot key fanout kind: \" + fanout.getKind());","typeGuard":null,"tryCatchPattern":"try { return combineWithFanout(fanout); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unexpected kind:\")) { /* fall back to non-fanout combine */ } throw e; }","preventionTips":["Only use the public withHotKeyFanout(int)/withHotKeyFanout(fn) API","Keep Beam versions consistent across construction and runners","Add regression tests when constructing combine options programmatically"],"tags":["java","apache-beam","group","hot-key-fanout","enum"],"backgroundTag":"invalid-enum-value","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"}