{"record":{"id":"3f4568aec4f937e1","repo":"gastownhall/beads","slug":"uow-database-name-must-not-be-empty-caller-shoul-3f4568","errorCode":null,"errorMessage":"uow: database name must not be empty (caller should default to %q)","messagePattern":"uow: database name must not be empty \\(caller should default to %q\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/uow/external_doltserver_provider.go","lineNumber":36,"sourceCode":"func NewExternalDoltServerUOWProvider(\n\tctx context.Context,\n\tserverRootDir string,\n\tdatabase string,\n\tserverLogFilePath string,\n\texternal configfile.ExternalDoltConfig,\n\trootUser string,\n\trootPassword string,\n\tproxyPort int,\n\tidleTimeout time.Duration,\n\tteamServer bool,\n\texpectedProjectID string,\n\topts ...ProviderOption,\n) (UnitOfWorkProvider, error) {\n\tif idleTimeout == 0 {\n\t\tidleTimeout = defaultProxyIdleTimeout\n\t}\n\tif database == \"\" {\n\t\treturn nil, fmt.Errorf(\"uow: database name must not be empty (caller should default to %q)\", \"beads\")\n\t}\n\tif rootUser == \"\" {\n\t\treturn nil, fmt.Errorf(\"uow: rootUser must not be empty\")\n\t}\n\tif err := external.Validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"uow: external: %w\", err)\n\t}\n\n\tabsServerRootDir, err := filepath.Abs(serverRootDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"uow: resolving server root dir: %w\", err)\n\t}\n\n\tif err := os.MkdirAll(absServerRootDir, config.BeadsDirPerm); err != nil {\n\t\treturn nil, fmt.Errorf(\"uow: creating server root directory: %w\", err)\n\t}\n\n\ttlsConfigName, err := registerExternalTLSConfig(external)","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/uow/external_doltserver_provider.go#L18-L54","documentation":"NewExternalDoltServerUOWProvider validates its inputs before creating a unit-of-work provider backed by an external Dolt server. The database name is mandatory because the provider must know which Dolt database to open and manage. The error message hints that the caller should have applied a default of \"beads\" before calling, so this error indicates a configuration gap that is normally handled by the caller layer.","triggerScenarios":"Calling NewExternalDoltServerUOWProvider with database set to \"\" (empty string), e.g. when a config struct field was never populated, an env var resolved to empty, or openProvider forwarded an empty db name.","commonSituations":"A beads config file lacks a `database` key; BD_DATABASE or similar env var is set but empty; a custom integration constructs the provider directly without defaulting the database name as the CLI layer does.","solutions":["Set the database name explicitly when calling NewExternalDoltServerUOWProvider","Default the value to \"beads\" at the call site if it is empty: if database == \"\" { database = \"beads\" }","Check where the database name comes from (config file / env var) and ensure the field is populated before provider construction"],"exampleFix":"// before\nprovider, err := uow.NewExternalDoltServerUOWProvider(ctx, cfg.Database, ...)\n// after\ndbName := cfg.Database\nif dbName == \"\" {\n    dbName = \"beads\"\n}\nprovider, err := uow.NewExternalDoltServerUOWProvider(ctx, dbName, ...)","handlingStrategy":"validation","validationCode":"if database == \"\" {\n    database = \"beads\" // apply library default before calling\n}\nif err := validateNonEmpty(database); err != nil {\n    return fmt.Errorf(\"config: database name missing: %w\", err)\n}","typeGuard":"func hasDatabaseName(db string) bool {\n    return strings.TrimSpace(db) != \"\"\n}","tryCatchPattern":"provider, err := uow.NewExternalDoltServerUOWProvider(ctx, db, root, dir, ext)\nif err != nil {\n    if strings.Contains(err.Error(), \"database name must not be empty\") {\n        return fmt.Errorf(\"misconfiguration: set database (default \\\"beads\\\") in config: %w\", err)\n    }\n    return err\n}","preventionTips":["Always default the database name to \"beads\" at the config-loading layer","Validate config struct fields immediately after unmarshalling, before constructing providers","Add a unit test asserting config loading never yields an empty database name"],"tags":["config","validation","uow","dolt"],"backgroundTag":"missing-required-config-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}