{"record":{"id":"83a6f521191e0d81","repo":"apache/beam","slug":"mutation-type-cannot-be-null","errorCode":null,"errorMessage":"Mutation type cannot be null.","messagePattern":"Mutation type cannot be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableWriteSchemaTransformProvider.java","lineNumber":264,"sourceCode":"      // convert all row inputs into KV<ByteString, Mutation>\n      PCollection<KV<ByteString, Mutation>> changedBeamRowMutationsList =\n          beamRowMutationsList.apply(\n              MapElements.into(\n                      TypeDescriptors.kvs(\n                          TypeDescriptor.of(ByteString.class), TypeDescriptor.of(Mutation.class)))\n                  .via(\n                      (Row input) -> {\n                        ByteString key =\n                            ByteString.copyFrom(\n                                Preconditions.checkStateNotNull(\n                                    input.getBytes(\"key\"),\n                                    \"Encountered row with null 'key' property.\"));\n\n                        Mutation bigtableMutation;\n                        String mutationType =\n                            input.getString(\"type\"); // Direct call, can return null\n                        if (mutationType == null) {\n                          throw new IllegalArgumentException(\"Mutation type cannot be null.\");\n                        }\n                        switch (mutationType) {\n                          case \"SetCell\":\n                            Mutation.SetCell.Builder setMutation =\n                                Mutation.SetCell.newBuilder()\n                                    .setValue(\n                                        ByteString.copyFrom(\n                                            Preconditions.checkStateNotNull(\n                                                input.getBytes(\"value\"),\n                                                \"Encountered SetCell mutation with null 'value' property.\")))\n                                    .setColumnQualifier(\n                                        ByteString.copyFrom(\n                                            Preconditions.checkStateNotNull(\n                                                input.getBytes(\"column_qualifier\"),\n                                                \"Encountered SetCell mutation with null 'column_qualifier' property. \")))\n                                    .setFamilyName(\n                                        Preconditions.checkStateNotNull(\n                                            input.getString(\"family_name\"),","sourceCodeStart":246,"sourceCodeEnd":282,"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#L246-L282","documentation":"In changeMutationInput, each input row's 'type' string selects which Bigtable Mutation to build. Since input.getString(\"type\") can return null when the field is absent, the provider explicitly throws IllegalArgumentException('Mutation type cannot be null.') to fail fast on rows missing this required discriminator.","triggerScenarios":"A Row in the input PCollection lacks the 'type' field or it is null — e.g. rows built with a schema that omits 'type', or data where the type column was never populated.","commonSituations":"CSV/JSON ingestion where an empty mutation-type column becomes null; partial schema evolution where older records predate the 'type' field.","solutions":["Ensure every input row has a non-null 'type' field with value SetCell, DeleteFamily, DeleteColumn, or DeleteRow","Add a validation/filter step upstream that drops or repairs rows with null type","Default the type in your ingestion pipeline where semantically safe (usually SetCell)"],"exampleFix":"// before\nRow row = Row.withSchema(schema).addValues(keyBytes, null, valueBytes).build();\n// after\nRow row = Row.withSchema(schema)\n    .addValues(keyBytes, \"SetCell\", valueBytes) // type always set\n    .build();","handlingStrategy":"type-guard","validationCode":"if (row.getSchema().hasField(\"type\") && row.getString(\"type\") == null) {\n  throw new IllegalArgumentException(\"Row missing mutation type: \" + row);\n}","typeGuard":"boolean hasMutationType(Row row) {\n  return row.getSchema().hasField(\"type\") && row.getString(\"type\") != null;\n}","tryCatchPattern":"try {\n  transform.expand(input);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Mutation type cannot be null\")) {\n    // quarantine the offending rows\n  }\n}","preventionTips":["Ensure the 'type' column is NOT NULL in source data","Coerce empty strings/nulls to a default type during ingestion","Add a Filter.by(r -> r.getString(\"type\") != null) step before the transform"],"tags":["gcp","bigtable","null","mutation"],"backgroundTag":"null-argument","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"}