{"record":{"id":"b8a22b3b444716b1","repo":"gastownhall/beads","slug":"invalid-database-name-q-use-cfg-getdoltdatabase","errorCode":null,"errorMessage":"invalid database name %q (use cfg.GetDoltDatabase() to resolve the configured name): %w","messagePattern":"invalid database name %q \\(use cfg\\.GetDoltDatabase\\(\\) to resolve the configured name\\): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/bootstrap.go","lineNumber":59,"sourceCode":"}\n\n// BootstrapFromRemoteWithDB is like BootstrapFromRemote but allows\n// specifying the database name (used by the embedded driver for the\n// subdirectory structure). The database parameter must not be empty;\n// callers should use cfg.GetDoltDatabase() which applies the fallback chain\n// (env var → config → default).\nfunc BootstrapFromRemoteWithDB(ctx context.Context, doltDir, remoteURL, database string) (bool, error) {\n\t// Skip if Dolt database already exists\n\tif doltExists(doltDir) {\n\t\treturn false, nil\n\t}\n\n\tif err := remotecache.ValidateRemoteURL(remoteURL); err != nil {\n\t\treturn false, fmt.Errorf(\"invalid remote URL: %w\", err)\n\t}\n\n\tif err := ValidateDatabaseName(database); err != nil {\n\t\treturn false, fmt.Errorf(\"invalid database name %q (use cfg.GetDoltDatabase() to resolve the configured name): %w\", database, err)\n\t}\n\n\t// Verify dolt CLI is available\n\tif _, err := exec.LookPath(\"dolt\"); err != nil {\n\t\treturn false, fmt.Errorf(\"dolt CLI not found (required for remote bootstrap): %w\", err)\n\t}\n\n\t// Create the parent dolt directory\n\tif err := os.MkdirAll(doltDir, 0o750); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to create dolt directory: %w\", err)\n\t}\n\n\t// Clone into <doltDir>/<database>/ so the embedded driver can find it.\n\t// `dolt clone <url> <target>` creates <target>/.dolt/ directly.\n\tcloneTarget := filepath.Join(doltDir, database)\n\t// Record whether the target already existed before this clone attempt.\n\t// If it did, the failed-clone cleanup below must never touch it: it\n\t// wasn't created by us, so it could be a pre-existing Dolt repo (e.g.","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/bootstrap.go#L41-L77","documentation":"BootstrapFromRemoteWithDB requires a non-empty database name and validates it with ValidateDatabaseName before cloning. The error means the database argument failed validation (empty, whitespace, or path-like characters). The message hints that callers should resolve the name via cfg.GetDoltDatabase(), which applies the fallback chain env var → config → default (\"beads\").","triggerScenarios":"Passing \"\", a whitespace-only string, or a string containing path separators/illegal characters as the database parameter to BootstrapFromRemoteWithDB or BootstrapFromGitRemoteWithDB instead of the resolved value from cfg.GetDoltDatabase().","commonSituations":"Calling bootstrap from custom tooling with a hardcoded empty database name; a config file where the dolt database key exists but is blank; passing a raw path like \".beads/dolt/beads\" instead of just the database name.","solutions":["Call bootstrap through the normal path so the database name comes from cfg.GetDoltDatabase() (env var → config → default \"beads\") instead of passing a raw/unresolved value.","If you must pass a name directly, supply a simple identifier (letters/digits/dashes, no slashes or spaces), e.g. \"beads\".","Check .beads/config.yaml and the relevant env var for an empty or whitespace database value and set a valid name.","Read the wrapped ValidateDatabaseName error (%w) — it states exactly which rule the name violated."],"exampleFix":"// before\nname := os.Getenv(\"BEADS_DB\") // may be empty\nbootstrap.BootstrapFromRemoteWithDB(ctx, doltDir, remote, name)\n// after\nname := cfg.GetDoltDatabase()\nbootstrap.BootstrapFromRemoteWithDB(ctx, doltDir, remote, name)","handlingStrategy":"validation","validationCode":"if err := dolt.ValidateDatabaseName(database); err != nil {\n    return fmt.Errorf(\"database name %q invalid: %w\", database, err)\n}","typeGuard":null,"tryCatchPattern":"ok, err := dolt.BootstrapFromRemoteWithDB(ctx, doltDir, remote, db)\nif err != nil && strings.Contains(err.Error(), \"invalid database name\") {\n    // fall back to the default chain: cfg.GetDoltDatabase() -> \"beads\"\n    db = cfg.GetDoltDatabase()\n}","preventionTips":["Always source the database name from cfg.GetDoltDatabase(), never from a raw env var or hand-built string.","Keep database names simple identifiers: no slashes, spaces, or path segments.","Validate the name at config-load time so failures surface before bootstrap."],"tags":["configuration","dolt","validation","bootstrap"],"backgroundTag":"invalid-database-name","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}