{"record":{"id":"f6c86898b1498e31","repo":"apache/beam","slug":"unexpected-mutation-type-s-s","errorCode":null,"errorMessage":"Unexpected mutation type [%s]: %s","messagePattern":"Unexpected mutation type \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableWriteSchemaTransformProvider.java","lineNumber":443,"sourceCode":"            break;\n          case \"DeleteFromFamily\":\n            bigtableMutation =\n                Mutation.newBuilder()\n                    .setDeleteFromFamily(\n                        Mutation.DeleteFromFamily.newBuilder()\n                            .setFamilyNameBytes(\n                                ByteString.copyFrom(ofNullable(mutation.get(\"family_name\")).get()))\n                            .build())\n                    .build();\n            break;\n          case \"DeleteFromRow\":\n            bigtableMutation =\n                Mutation.newBuilder()\n                    .setDeleteFromRow(Mutation.DeleteFromRow.newBuilder().build())\n                    .build();\n            break;\n          default:\n            throw new RuntimeException(\n                String.format(\n                    \"Unexpected mutation type [%s]: %s\",\n                    Arrays.toString(ofNullable(mutation.get(\"type\")).get()), mutation));\n        }\n        mutations.add(bigtableMutation);\n      }\n      return KV.of(key, mutations);\n    }\n  }\n}\n","sourceCodeStart":425,"sourceCodeEnd":454,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableWriteSchemaTransformProvider.java#L425-L454","documentation":"In BigtableWriteSchemaTransformProvider's inner apply (mutation-map based input), each mutation map's 'type' selects the Mutation to build. The default branch throws a RuntimeException with the unsupported type and the full mutation map when the type isn't a known one; note ofNullable(mutation.get(\"type\")).get() will throw NoSuchElementException if 'type' is missing entirely.","triggerScenarios":"Passing a mutation map with a 'type' key that is not SetCell/DeleteFamily/DeleteColumn/DeleteRow, or a map missing 'type' entirely (which triggers NoSuchElementException inside this error path).","commonSituations":"Programmatically generated mutation maps with typos in the type field; mixing user-authored mutation maps from different APIs; JSON/YAML configs with incorrect type names.","solutions":["Set 'type' in each mutation map to exactly one of SetCell, DeleteFamily, DeleteColumn, DeleteRow","Guard for a missing 'type' key before calling the transform to get a clearer error than NoSuchElementException","Log the full mutation map (included in the message) to identify and correct the bad record"],"exampleFix":"// before\nMap<String, ByteString> mutation = ImmutableMap.of(\"Type\", cellBytes); // wrong key/type\n// after\nMap<String, ByteString> mutation = ImmutableMap.of(\n    \"type\", ByteString.copyFromUtf8(\"SetCell\"),\n    \"family_name\", ByteString.copyFromUtf8(\"cf\"),\n    \"column_qualifier\", ByteString.copyFromUtf8(\"cq\"),\n    \"value\", cellBytes);","handlingStrategy":"validation","validationCode":"boolean validMutationMap(Map<String, ByteString> m) {\n  ByteString t = m.get(\"type\");\n  return t != null && Set.of(\"SetCell\",\"DeleteFamily\",\"DeleteColumn\",\"DeleteRow\")\n      .contains(t.toStringUtf8());\n}","typeGuard":"boolean hasKnownType(Map<String, ByteString> mutation) {\n  ByteString t = mutation.get(\"type\");\n  return t != null && switch (t.toStringUtf8()) {\n    case \"SetCell\", \"DeleteFamily\", \"DeleteColumn\", \"DeleteRow\" -> true;\n    default -> false;\n  };\n}","tryCatchPattern":"try {\n  apply(mutations);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Unexpected mutation type\")) {\n    // fix or drop the mutation map logged in the message\n  }\n}","preventionTips":["Always include a 'type' key with an exact valid value in mutation maps","Validate each map with a guard before calling the transform","Never assume the map format — check the documented mutation schema keys (family_name, column_qualifier, value, etc.)"],"tags":["gcp","bigtable","mutation","validation"],"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-14T21:17:11.552Z"}