{"record":{"id":"381d6994a9287291","repo":"gastownhall/beads","slug":"database-name-q-contains-hyphens-which-are-invali","errorCode":null,"errorMessage":"database name %q contains hyphens which are invalid in embedded mode; use underscores instead (e.g. %q)","messagePattern":"database name %q contains hyphens which are invalid in embedded mode; use underscores instead \\(e\\.g\\. %q\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":726,"sourceCode":"\t\t// Explicit connection flags outrank stale BEADS_DOLT_SERVER_* values\n\t\t// (GH#5177). This must run AFTER every source of server mode has been\n\t\t// consulted above: --server, BEADS_DOLT_SERVER_MODE, --shared-server,\n\t\t// workspace inheritance, and config.yaml dolt.mode. In embedded mode\n\t\t// the flags are still recorded in metadata.json, but promoting them\n\t\t// into the environment would trip init's own remote-host guard below.\n\t\tif initServerMode {\n\t\t\trestoreServerConnEnv, err := promoteExplicitServerConnFlags(cmd)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer restoreServerConnEnv()\n\t\t}\n\n\t\t// Reject hyphens in --database for embedded mode. Must run AFTER\n\t\t// serverMode is set above — otherwise !usesSQLServer() always returns\n\t\t// true and incorrectly rejects server-mode names (GH#3231).\n\t\tif database != \"\" && strings.ContainsRune(database, '-') && !usesSQLServer() {\n\t\t\treturn fmt.Errorf(\"database name %q contains hyphens which are invalid in embedded mode; use underscores instead (e.g. %q)\",\n\t\t\t\tdatabase, sanitizeDBName(database))\n\t\t}\n\n\t\t// Hard fail: if a remote dolt.host is configured, server mode MUST\n\t\t// be active — embedded mode has no host. dolt.port alone is ambient\n\t\t// plumbing (e.g. test harnesses) and is not treated as server intent.\n\t\tif !initServerMode {\n\t\t\tconfigHost := config.GetYamlConfig(\"dolt.host\")\n\t\t\tenvHost := os.Getenv(\"BEADS_DOLT_SERVER_HOST\")\n\t\t\tconfigPort := config.GetYamlConfig(\"dolt.port\")\n\t\t\tenvPort := os.Getenv(\"BEADS_DOLT_SERVER_PORT\")\n\n\t\t\tif conflict := detectInitRemoteHostConflict(configHost, envHost, configPort, envPort); conflict != nil {\n\t\t\t\tdetail := fmt.Sprintf(\"dolt.host (%s) is\", conflict.host)\n\t\t\t\tif conflict.includesPort {\n\t\t\t\t\tdetail = fmt.Sprintf(\"dolt.host (%s) and dolt.port are\", conflict.host)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"%s set via %s but server mode is not enabled.\\n\"+","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L708-L744","documentation":"bd init rejects a --database name containing hyphens when running in embedded mode (no SQL server). Hyphens are invalid identifiers for the embedded Dolt database, so bd fails fast with a suggested sanitized name. This check must run after server mode detection so server-mode names are not wrongly rejected.","triggerScenarios":"Running `bd init --database my-db` (or config dolt.database with hyphens) while the workspace resolves to embedded mode, i.e. !usesSQLServer() (no --server, no dolt.mode: server, no remote dolt.host).","commonSituations":"Users copying database names from branch names or project slugs like 'proj-alpha'; CI scripts templating names from git branch names which contain hyphens.","solutions":["Replace hyphens with underscores: bd init --database my_db","Use the suggested name shown in the error message (sanitizeDBName output)","Switch to server mode if hyphenated names are required: dolt.mode: server in config or pass --server to bd init"],"exampleFix":"// before\nbd init --database beads-proj-alpha\n// after\nbd init --database beads_proj_alpha","handlingStrategy":"validation","validationCode":"if [[ \"$DB_NAME\" == *-* ]]; then echo \"Use underscores instead of hyphens: ${DB_NAME//-/_}\"; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive database names from branch/slug names with tr '-' '_' before passing to bd init","Keep a project convention: always lowercase, underscore-separated database names","Enable server mode explicitly in config if you need hyphenated names"],"tags":["cli","validation","database-name","embedded-mode"],"backgroundTag":"invalid-database-name","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}