{"record":{"id":"0330c8086d029443","repo":"apache/beam","slug":"unknown-mutation-operation-type-s","errorCode":null,"errorMessage":"Unknown mutation operation type: %s","messagePattern":"Unknown mutation operation type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtils.java","lineNumber":80,"sourceCode":"   * @return function that can convert row to mutation\n   */\n  public static SerializableFunction<Row, Mutation> beamRowToMutationFn(\n      Mutation.Op operation, String table) {\n    return row -> {\n      switch (operation) {\n        case INSERT:\n          return MutationUtils.createMutationFromBeamRows(Mutation.newInsertBuilder(table), row);\n        case DELETE:\n          return Mutation.delete(table, MutationUtils.createKeyFromBeamRow(row));\n        case UPDATE:\n          return MutationUtils.createMutationFromBeamRows(Mutation.newUpdateBuilder(table), row);\n        case REPLACE:\n          return MutationUtils.createMutationFromBeamRows(Mutation.newReplaceBuilder(table), row);\n        case INSERT_OR_UPDATE:\n          return MutationUtils.createMutationFromBeamRows(\n              Mutation.newInsertOrUpdateBuilder(table), row);\n        default:\n          throw new IllegalArgumentException(\n              String.format(\"Unknown mutation operation type: %s\", operation));\n      }\n    };\n  }\n\n  private static Key createKeyFromBeamRow(Row row) {\n    Key.Builder builder = Key.newBuilder();\n    Schema schema = row.getSchema();\n    List<String> columns = schema.getFieldNames();\n    columns.forEach(\n        columnName ->\n            setBeamValueToKey(builder, schema.getField(columnName).getType(), columnName, row));\n    return builder.build();\n  }\n\n  public static Mutation createMutationFromBeamRows(\n      Mutation.WriteBuilder mutationBuilder, Row row) {\n    Schema schema = row.getSchema();","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtils.java#L62-L98","documentation":"MutationUtils.beamRowToMutationFn() translates the configured mutation operation (INSERT, UPDATE, INSERT_OR_UPDATE, REPLACE, DELETE) into the corresponding Spanner Mutation builder. An operation value outside the known switch cases throws IllegalArgumentException('Unknown mutation operation type: %s').","triggerScenarios":"Configuring the Spanner write connector with a mutation operation string that is misspelled, lower-cased (e.g. 'insert' vs 'INSERT'), or empty; the enum lookup yields an unexpected value at pipeline construction.","commonSituations":"Pipeline options/YAML supplying a wrong operation name; upstream refactor renaming the enum; passing a custom string where a MutationOperation enum is expected.","solutions":["Set the operation to one of: INSERT, UPDATE, UPSERT (INSERT_OR_UPDATE), REPLACE, DELETE — exact enum name.","Normalize/trim the operation string before building the transform.","Check which enum type is expected by the connector version in use (API names changed across versions)."],"exampleFix":"// before\nSpannerWrite.withMutationOperation(\"upsert\")\n// after\nSpannerWrite.withMutationOperation(\"UPSERT\") // or INSERT_OR_UPDATE depending on API version","handlingStrategy":"validation","validationCode":"Set<String> OPS = Set.of(\"INSERT\",\"UPDATE\",\"UPSERT\",\"REPLACE\",\"DELETE\");\nif (!OPS.contains(operation.trim().toUpperCase())) throw new IllegalArgumentException(\"unknown operation: \" + operation);","typeGuard":"boolean isKnownOperation(String op) { return java.util.Arrays.stream(MutationOp.values()).anyMatch(m -> m.name().equalsIgnoreCase(op)); }","tryCatchPattern":"try { rowToMutationFn = MutationUtils.beamRowToMutationFn(table, op); } catch (IllegalArgumentException e) { /* correct the op enum */ }","preventionTips":["Reference the enum constant (e.g. MutationOp.UPSERT) instead of raw strings","Normalize casing of operation config at the boundary","Add a startup-time validation of pipeline options"],"tags":["java","apache-beam","spanner","config"],"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"}