apache/beam · critical
no database provided!
Error message
no database provided!
What it means
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.
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.
Example fix
// before
spannerio.Write(s, db, "users", col)
// after
if db == "" {
panic("set --spanner_db flag")
}
spannerio.Write(s, db, "users", col) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(db) == "" {
return fmt.Errorf("spanner database path is required for Write")
} Try / catch
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("spannerio.Write: %v", r)
}
}() Prevention
- 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.
When it happens
Trigger: Calling spannerio.Write(s, "", table, col) or passing an uninitialized db variable.
Common situations: Missing Spanner database config, env vars not loaded, or pipelines parameterized from flags with no value set.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- database not provided!
- no database provided
- no database provided!
- spannerio.Query: invalid option
- unable to create batch read only transaction:
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/3d66eafe3efa3444.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/spannerio/write.go:51
type WriteOptionsFn func(qo *writeOptions) error
type writeOptions struct {
BatchSize int
}
// UseBatchSize explicitly sets the batch size per transaction for writes.
func UseBatchSize(batchSize int) WriteOptionsFn {
return func(qo *writeOptions) error {
qo.BatchSize = batchSize
return nil
}
}
// Write writes the elements of the given PCollection<T> to spanner. T is required
// to be the schema type.
func Write(s beam.Scope, db string, table string, col beam.PCollection, options ...WriteOptionsFn) {
if db == "" {
panic("no database provided!")
}
if typex.IsCoGBK(col.Type()) || typex.IsKV(col.Type()) {
panic("unsupported collection type - only normal structs supported for writing.")
}
s = s.Scope("spanner.Write")
beam.ParDo0(s, newWriteFn(db, table, col.Type().Type(), options...), col)
}
type writeFn struct {
spannerFn
Table string `json:"table"` // The table to write to
Type beam.EncodedType `json:"type"` // Type is the encoded schema type.
Options writeOptions `json:"options"` // Spanner write options
mutations []*spanner.Mutation
}View on GitHub (pinned to 12126d8942)