{"record":{"id":"feca7fec9a7ca6f0","repo":"apache/beam","slug":"err-bigtable","errorCode":null,"errorMessage":"err","messagePattern":"err","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/io/bigtableio/bigtable.go","lineNumber":79,"sourceCode":"// analogue to bigtable.Mutation.Set().\n// The timestamp will be truncated to millisecond granularity.\n// A timestamp of ServerTime means to use the server timestamp.\nfunc (m *Mutation) Set(family, column string, ts bigtable.Timestamp, value []byte) {\n\tm.Ops = append(m.Ops, Operation{Family: family, Column: column, Ts: ts, Value: value})\n}\n\n// WithGroupKey sets a custom group key to be utilised by beam.GroupByKey.\nfunc (m *Mutation) WithGroupKey(key string) *Mutation {\n\tm.GroupKey = key\n\treturn m\n}\n\n// Write writes the elements of the given PCollection<bigtableio.Mutation> to bigtable.\nfunc Write(s beam.Scope, project, instanceID, table string, col beam.PCollection) {\n\tt := col.Type().Type()\n\terr := mustBeBigtableioMutation(t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ts = s.Scope(\"bigtable.Write\")\n\n\tpre := beam.ParDo(s, addGroupKeyFn, col)\n\tpost := beam.GroupByKey(s, pre)\n\tbeam.ParDo0(s, &writeFn{Project: project, InstanceID: instanceID, TableName: table, Type: beam.EncodedType{T: t}}, post)\n}\n\n// WriteBatch writes the elements of the given PCollection<bigtableio.Mutation>\n// to bigtable using bigtable.ApplyBulk().\n// For the underlying bigtable.ApplyBulk function to work properly\n// the maximum number of operations per bigtableio.Mutation of the input\n// PCollection must not be greater than 100,000. For more information\n// see https://cloud.google.com/bigtable/docs/writes#batch for more.\nfunc WriteBatch(s beam.Scope, project, instanceID, table string, col beam.PCollection) {\n\tt := col.Type().Type()\n\terr := mustBeBigtableioMutation(t)","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/bigtableio/bigtable.go#L61-L97","documentation":"bigtableio.Write panics when the input PCollection's element type is not bigtableio.Mutation. mustBeBigtableioMutation checks col.Type().Type() and returns an error when the element type differs; Write immediately panics with that error because the connector can only write Bigtable mutations.","triggerScenarios":"Calling bigtableio.Write(s, project, instanceID, table, col) where col's element type is a raw string, []byte, custom struct, or any type other than bigtableio.Mutation.","commonSituations":"Passing a PCollection of row keys or plain values straight into Write without first converting them to Mutation via bigtableio.NewMutation; wiring up a pipeline copied from another IO connector's example.","solutions":["Transform the input PCollection so each element is a *bigtableio.Mutation (use a beam.ParDo that builds Mutations from your data).","Guard before calling: verify reflect.TypeOf(bigtableio.Mutation{}) is assignable from col.Type().Type().","Use bigtableio.NewMutation(rowKey, family, column, value, timestamp) helpers to construct elements."],"exampleFix":"// before\nbigtableio.Write(s, proj, inst, table, beam.Create(s, \"row1\"))\n\n// after\nmut := beam.ParDo(s, func(key string) *bigtableio.Mutation {\n    return bigtableio.NewMutation(key, \"cf\", \"col\", []byte(\"v\"), bigtableio.ServerTimestamp)\n}, beam.Create(s, \"row1\"))\nbigtableio.Write(s, proj, inst, table, mut)","handlingStrategy":"type-guard","validationCode":"if col.Type().Type() != reflect.TypeOf((*bigtableio.Mutation)(nil)).Elem() {\n    return fmt.Errorf(\"bigtableio.Write requires PCollection<bigtableio.Mutation>, got %v\", col.Type().Type())\n}","typeGuard":"func isMutationCol(col beam.PCollection) bool {\n    return col.Type().Type() == reflect.TypeOf((*bigtableio.Mutation)(nil)).Elem()\n}","tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        log.Fatalf(\"bigtable write setup failed: %v\", r)\n    }\n}()","preventionTips":["Always map source data to *bigtableio.Mutation before Write.","Keep a shared DoFn for building mutations from your domain types.","Check element type when connecting different IO stages."],"tags":["go","bigtable","panic","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}