{"record":{"id":"e2598e70771d681f","repo":"apache/beam","slug":"type-must-be-bigtableio-mutation-but-is-v","errorCode":null,"errorMessage":"type must be bigtableio.Mutation but is: %v","messagePattern":"type must be bigtableio\\.Mutation but is: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/bigtableio/bigtable.go","lineNumber":124,"sourceCode":"\tbeam.ParDo0(s, &writeBatchFn{Project: project, InstanceID: instanceID, TableName: table, Type: beam.EncodedType{T: t}}, post)\n}\n\nfunc addGroupKeyFn(mutation Mutation) (int, Mutation) {\n\tif mutation.GroupKey != \"\" {\n\t\treturn hashStringToInt(mutation.GroupKey), mutation\n\t}\n\treturn 1, mutation\n}\n\nfunc hashStringToInt(s string) int {\n\th := fnv.New32a()\n\th.Write([]byte(s))\n\treturn int(h.Sum32())\n}\n\nfunc mustBeBigtableioMutation(t reflect.Type) error {\n\tif t != reflect.TypeOf(Mutation{}) {\n\t\treturn fmt.Errorf(\"type must be bigtableio.Mutation but is: %v\", t)\n\t}\n\treturn nil\n}\n\ntype writeFn struct {\n\t// Project is the project\n\tProject string `json:\"project\"`\n\t// InstanceID is the bigtable instanceID\n\tInstanceID string `json:\"instanceId\"`\n\t// Client is the bigtable.Client\n\tclient *bigtable.Client `json:\"-\"`\n\t// TableName is the qualified table identifier.\n\tTableName string `json:\"tableName\"`\n\t// Table is a bigtable.Table instance with an eventual open connection\n\ttable *bigtable.Table `json:\"-\"`\n\t// Type is the encoded schema type.\n\tType beam.EncodedType `json:\"type\"`\n}","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/bigtableio/bigtable.go#L106-L142","documentation":"bigtableio requires that the PCollection being written consists of exactly bigtableio.Mutation elements. mustBeBigtableioMutation checks the element type at pipeline construction and rejects any other type with this error, failing fast before job submission.","triggerScenarios":"Calling bigtableio.Write or bigtableio.WriteBatch with a PCollection whose element type is not bigtableio.Mutation (e.g. []byte, custom struct, Mutation pointer).","commonSituations":"Passing a custom row-mutation struct instead of converting to bigtableio.Mutation; using a pointer type *Mutation; feeding output of another transform directly without conversion.","solutions":["Map your data to bigtableio.Mutation values (with NewMutation / getBigtableMutation helpers or manual construction) before Write.","Ensure the PCollection is beam.V(Mutation{}) typed, not a pointer or slice.","Inspect the PCollection's element type at graph-construction time if types are inferred."],"exampleFix":"// before\nbigtableio.Write(s, project, instance, table, colFamily, typedCol)\n// after\nmutations := beam.ParDo(s, func(k string, v []byte) bigtableio.Mutation {\n    return bigtableio.Mutation{RowKey: k, ColumnFamily: colFamily, Column: \"data\", Value: v}\n}, typedCol)\nbigtableio.Write(s, project, instance, table, colFamily, mutations)","handlingStrategy":"type-guard","validationCode":"if col.Type() != reflect.TypeOf(bigtableio.Mutation{}) {\n    panic(\"PCollection element type must be bigtableio.Mutation\")\n}","typeGuard":"func isMutationCol(col beam.Node) bool {\n    return col.Type() == reflect.TypeOf(bigtableio.Mutation{})\n}","tryCatchPattern":"defer func() {\n    if r := recover(); r != nil && strings.Contains(fmt.Sprint(r), \"type must be bigtableio.Mutation\") {\n        // fix PCollection element type before Write\n    }\n}()","preventionTips":["Always map input data to bigtableio.Mutation values (not pointers) before Write.","Use beam.TryInfer / check element types early in pipeline construction."],"tags":["bigtable","type-mismatch","beam","go"],"backgroundTag":"type-mismatch","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"}