{"record":{"id":"cfe895a3c2fbbb80","repo":"gastownhall/beads","slug":"invalid-database-name-q-v","errorCode":null,"errorMessage":"invalid database name %q: %v","messagePattern":"invalid database name %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":560,"sourceCode":"\t\t\treturn fmt.Errorf(\"unknown backend %q: the supported backend is \\\"dolt\\\" (default)\", backendFlag)\n\t\t}\n\t\t// A registered extension backend passes IsSupportedBackend so its\n\t\t// existing workspaces can be opened, but init provisions Dolt only and\n\t\t// would otherwise create the workspace and persist backend: dolt. Reject\n\t\t// it here rather than silently creating the wrong workspace; downstream\n\t\t// registrants supply their own workspace-creation path.\n\t\tif backends.Registered(backendFlag) {\n\t\t\treturn fmt.Errorf(\"backend %q cannot be created by bd init; it can only open an existing workspace (bd init provisions \\\"dolt\\\", the default)\", backendFlag)\n\t\t}\n\t\tfor _, legacyFlag := range removedBackendInitFlags {\n\t\t\tif cmd.Flags().Changed(legacyFlag.name) {\n\t\t\t\treturn fmt.Errorf(\"--%s belonged to %s: %s; use --backend=dolt (the default)\", legacyFlag.name, legacyFlag.origin, legacyFlag.rationale)\n\t\t\t}\n\t\t}\n\t\t// Validate --database format early, before any side effects.\n\t\tif database != \"\" {\n\t\t\tif err := dolt.ValidateDatabaseName(database); err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid database name %q: %v\", database, err)\n\t\t\t}\n\t\t}\n\n\t\t// Resolve non-interactive mode: flag > env var > terminal detection.\n\t\t// This must be computed before any interactive prompts.\n\t\tnonInteractive := isNonInteractiveInit(nonInteractiveFlag)\n\n\t\t// Validate --role flag value\n\t\tif roleFlag != \"\" {\n\t\t\tswitch roleFlag {\n\t\t\tcase \"maintainer\", \"contributor\":\n\t\t\t\t// valid\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"invalid --role %q: must be \\\"maintainer\\\" or \\\"contributor\\\"\", roleFlag)\n\t\t\t}\n\t\t}\n\n\t\t// Fail-fast: contributor/team wizards require interaction","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L542-L578","documentation":"Wraps dolt.ValidateDatabaseName's error when the --database flag value is not a valid Dolt database name. Validation runs early in init, before any side effects, and the %v carries the specific rule the name violated.","triggerScenarios":"`bd init --database=<name>` where name fails dolt.ValidateDatabaseName (e.g. contains hyphens, spaces, special chars, starts with a digit, or is empty-string-adjacent malformed).","commonSituations":"Using hyphenated project names ('my-project') as database names, spaces or slashes from paths, names copied from directory names with invalid characters.","solutions":["Use only letters, digits, and underscores; start with a letter or underscore","Convert hyphens to underscores: my-project → my_project","Check the wrapped %v message for the exact violated rule","Drop --database and let init choose the default database name"],"exampleFix":"// before\nbd init --database=my-project\n// after\nbd init --database=my_project","handlingStrategy":"validation","validationCode":"var dbRE = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`)\nif database != \"\" && !dbRE.MatchString(database) {\n    return fmt.Errorf(\"database name %q invalid; use letters, digits, underscores\", database)\n}","typeGuard":null,"tryCatchPattern":"if err := dolt.ValidateDatabaseName(database); err != nil {\n    return fmt.Errorf(\"invalid database name %q: %w\", database, err)\n}","preventionTips":["Sanitize project names: replace hyphens/spaces with underscores","Start database names with a letter or underscore","Validate with dolt.ValidateDatabaseName before invoking init"],"tags":["cli","init","database-name","validation"],"backgroundTag":"invalid-identifier","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}