{"record":{"id":"16b213e5092b9071","repo":"apache/beam","slug":"invalid-schema-type-v","errorCode":null,"errorMessage":"invalid schema type: %v","messagePattern":"invalid schema type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/io/bigqueryio/bigquery.go","lineNumber":229,"sourceCode":"\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\temit(reflect.ValueOf(val).Elem().Interface()) // emit(*val)\n\t}\n\treturn nil\n}\n\nfunc mustInferSchema(t reflect.Type) bigquery.Schema {\n\tif t.Kind() != reflect.Struct {\n\t\tpanic(fmt.Sprintf(\"schema type must be struct: %v\", t))\n\t}\n\n\tcheckTypeRegistered(t)\n\n\tschema, err := bigquery.InferSchema(reflect.Zero(t).Interface())\n\tif err != nil {\n\t\tpanic(errors.Wrapf(err, \"invalid schema type: %v\", t))\n\t}\n\treturn schema\n}\n\nfunc checkTypeRegistered(t reflect.Type) {\n\tt = reflectx.SkipPtr(t)\n\tkey, ok := runtime.TypeKey(t)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"type %v must be a named type (not anonymous) for registration\", t))\n\t}\n\n\tif _, registered := runtime.LookupType(key); !registered {\n\t\tpanic(fmt.Sprintf(\"type %v is not registered. Ensure that beam.RegisterType(%v) \"+\n\t\t\t\"is called before beam.Init().\", t, t))\n\t}\n}\n\nfunc mustParseTable(table string) QualifiedTableName {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/bigqueryio/bigquery.go#L211-L247","documentation":"mustInferSchema uses the cloud.google.com/go/bigquery InferSchema on a zero value of the element type to derive a BigQuery table schema. If InferSchema cannot map the Go type to BigQuery fields (unsupported field types, nested pointers/maps, unexported or recursive fields), it returns an error and mustInferSchema panics with \"invalid schema type: %v\", naming the reflect.Type. This is a programming/config error: the type handed to bigqueryio is not schema-inferable.","triggerScenarios":"Calling bigqueryio.Query or bigqueryio.Write with an element type that bigquery.InferSchema rejects: maps, unsupported nested types, interface fields, or a type not registered for gob when required by the pipeline encoding path.","commonSituations":"Writing rows using ad-hoc structs with fields BigQuery cannot represent; after refactoring a struct to add a map or interface field; passing a named type whose underlying structure has unsupported members; missing gob registration of the element type in distributed execution.","solutions":["Replace unsupported fields (map, interface, recursive pointers) in the element struct with supported types or a *bigquery.QueryParameterValue-style representation.","Use bigqueryio.WithSchema (or WithQuerySchema for queries) to supply an explicit bigquery.Schema instead of relying on inference.","Register the element type with gob (gob.Register) if the failure comes from checkTypeRegistered on an unregistered custom type.","Test inference locally by calling bigquery.InferSchema(reflect.Zero(t).Interface()) directly to see the underlying unsupported-field error."],"exampleFix":"// before\ntype row struct {\n\tTags map[string]string\n}\nbeam.ParDo(s, fn) // bigqueryio.Write panics: invalid schema type\n\n// after\nbigqueryio.Write(s, project, dataset, table, []bigqueryio.WithSchema{bigqueryio.WithSchema(bigquery.Schema{\n\t{Name: \"Tags\", Type: bigquery.StringFieldType, Repeated: true},\n})})","handlingStrategy":"validation","validationCode":"if _, err := bigquery.InferSchema(reflect.Zero(elemType).Interface()); err != nil {\n\t// fail fast: use bigqueryio.WithSchema(...) with an explicit schema instead\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep sink element structs limited to BigQuery-mappable field types (no maps/interfaces/recursive pointers).","Prefer explicit WithSchema over schema inference in production pipelines.","gob.Register every custom type used as a PCollection element.","Add a unit test that infers the schema for each sink element type."],"tags":["bigquery","schema","go","apache-beam"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}