{"record":{"id":"3d66eafe3efa3444","repo":"apache/beam","slug":"no-database-provided-write","errorCode":null,"errorMessage":"no database provided!","messagePattern":"no database provided!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/io/spannerio/write.go","lineNumber":51,"sourceCode":"type WriteOptionsFn func(qo *writeOptions) error\n\ntype writeOptions struct {\n\tBatchSize int\n}\n\n// UseBatchSize explicitly sets the batch size per transaction for writes.\nfunc UseBatchSize(batchSize int) WriteOptionsFn {\n\treturn func(qo *writeOptions) error {\n\t\tqo.BatchSize = batchSize\n\t\treturn nil\n\t}\n}\n\n// Write writes the elements of the given PCollection<T> to spanner. T is required\n// to be the schema type.\nfunc Write(s beam.Scope, db string, table string, col beam.PCollection, options ...WriteOptionsFn) {\n\tif db == \"\" {\n\t\tpanic(\"no database provided!\")\n\t}\n\n\tif typex.IsCoGBK(col.Type()) || typex.IsKV(col.Type()) {\n\t\tpanic(\"unsupported collection type - only normal structs supported for writing.\")\n\t}\n\n\ts = s.Scope(\"spanner.Write\")\n\n\tbeam.ParDo0(s, newWriteFn(db, table, col.Type().Type(), options...), col)\n}\n\ntype writeFn struct {\n\tspannerFn\n\tTable     string           `json:\"table\"`   // The table to write to\n\tType      beam.EncodedType `json:\"type\"`    // Type is the encoded schema type.\n\tOptions   writeOptions     `json:\"options\"` // Spanner write options\n\tmutations []*spanner.Mutation\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/spannerio/write.go#L33-L69","documentation":"Panic raised at pipeline-construction time by spannerio.Write when the db argument is an empty string. The Spanner write transform needs a 'projects/.../instances/.../databases/...' database name to target; an empty one is almost always a missing/blank configuration value, and failing fast at graph construction prevents a broken pipeline from being submitted.","triggerScenarios":"Calling spannerio.Write(s, \"\", table, col) or passing an uninitialized db variable.","commonSituations":"Missing Spanner database config, env vars not loaded, or pipelines parameterized from flags with no value set.","solutions":["Pass a non-empty database path projects/<proj>/instances/<inst>/databases/<db> to Write.","Validate the db string before constructing the pipeline.","Wire the database name through pipeline options so it is required at startup."],"exampleFix":"// before\nspannerio.Write(s, db, \"users\", col)\n// after\nif db == \"\" {\n    panic(\"set --spanner_db flag\")\n}\nspannerio.Write(s, db, \"users\", col)","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(db) == \"\" {\n    return fmt.Errorf(\"spanner database path is required for Write\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"spannerio.Write: %v\", r)\n    }\n}()","preventionTips":["Load and verify Spanner connection config before building the pipeline graph.","Reuse the same config-validation helper for both spannerio.Query and spannerio.Write.","Fail in flag.Parse/option validation rather than deep in pipeline construction."],"tags":["go","apache-beam","spanner","panic"],"backgroundTag":"missing-required-argument","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"}