{"record":{"id":"24139d404ee6f3cc","repo":"apache/beam","slug":"no-database-provided","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/generate_partitions.go","lineNumber":71,"sourceCode":"}\n\nfunc partitionOptions(options queryOptions) spanner.PartitionOptions {\n\tpartitionOptions := spanner.PartitionOptions{}\n\n\tif options.MaxPartitions != 0 {\n\t\tpartitionOptions.MaxPartitions = options.MaxPartitions\n\t}\n\n\treturn partitionOptions\n}\n\nfunc newGeneratePartitionsFn(\n\tdb string,\n\tquery string,\n\toptions queryOptions,\n) *generatePartitionsFn {\n\tif db == \"\" {\n\t\tpanic(\"no database provided\")\n\t}\n\n\treturn &generatePartitionsFn{\n\t\tspannerFn: newSpannerFn(db),\n\t\tQuery:     query,\n\t\tOptions:   options,\n\t}\n}\n\nfunc (f *generatePartitionsFn) ProcessElement(ctx context.Context, _ []byte, emit func(partitionedRead)) error {\n\ttxn, err := f.client.BatchReadOnlyTransaction(ctx, f.Options.TimestampBound)\n\tif err != nil {\n\t\tpanic(\"unable to create batch read only transaction: \" + err.Error())\n\t}\n\tdefer txn.Close()\n\n\tmode := spannerpb.ExecuteSqlRequest_PROFILE\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/spannerio/generate_partitions.go#L53-L89","documentation":"newGeneratePartitionsFn panics when the database string is empty while building the partitioned-query DoFn. Like the rest of spannerio, partitioned reads require a fully qualified database path and treat a missing one as an immediate construction error.","triggerScenarios":"Calling spannerio's partitioned-query entry point (generatePartitions path) with db == \"\".","commonSituations":"Empty Spanner database env var or pipeline option; constructing the DoFn in a test with placeholder arguments; refactoring that dropped the database parameter.","solutions":["Provide the full database path projects/<proj>/instances/<inst>/databases/<db>.","Validate db != \"\" before invoking the generate-partitions API.","Ensure the pipeline option/flag feeding the database is parsed and non-empty."],"exampleFix":"// before\ngeneratePartitions(s, \"\", query, opts)\n// after\nconst db = \"projects/my-proj/instances/my-inst/databases/my-db\"\ngeneratePartitions(s, db, query, opts)","handlingStrategy":"validation","validationCode":"if db == \"\" {\n    return errors.New(\"no database provided for generatePartitions\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if s, ok := r.(string); ok && s == \"no database provided\" {\n            // handle\n        } else { panic(r) }\n    }\n}()","preventionTips":["Validate the db argument before constructing the partitions DoFn.","Centralize database-path construction in one helper with validation.","Add startup checks for the config source supplying the database."],"tags":["go","apache-beam","spanner","panic","missing-argument"],"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-14T16:17:12.679Z"}