gastownhall/beads · error
database name too long
Error message
database name too long
What it means
ValidateDatabaseName rejects any database name longer than 64 characters. Dolt, like MySQL, limits identifiers to 64 bytes, and the name is interpolated into CREATE DATABASE statements, so an over-long name would fail server-side anyway. The check runs before any query is issued, so callers get a deterministic client-side error instead of a driver error.
Source
Thrown at internal/storage/dolt/history.go:34
var validTablePattern = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`)
// validDatabasePattern matches valid MySQL database names (alphanumeric, underscore, hyphen)
var validDatabasePattern = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_\-]*$`)
// validateRef checks if a ref is safe to use in queries.
// Delegates to issueops.ValidateRef.
func validateRef(ref string) error {
return issueops.ValidateRef(ref)
}
// ValidateDatabaseName checks if a database name is safe to use in queries.
// Prevents SQL injection via backtick escaping in CREATE DATABASE statements.
func ValidateDatabaseName(name string) error {
if name == "" {
return fmt.Errorf("database name cannot be empty")
}
if len(name) > 64 {
return fmt.Errorf("database name too long")
}
if !validDatabasePattern.MatchString(name) {
return fmt.Errorf("invalid database name: %s", name)
}
return nil
}
// validateTableName checks if a table name is safe to use in queries
func validateTableName(table string) error {
if table == "" {
return fmt.Errorf("table name cannot be empty")
}
if len(table) > 64 {
return fmt.Errorf("table name too long")
}
if !validTablePattern.MatchString(table) {
return fmt.Errorf("invalid table name: %s", table)
}View on GitHub (pinned to 71377f2769)
Solutions
- Shorten the database name to 64 characters or fewer (len(name) <= 64) before passing it to any dolt store bootstrap/connect function.
- If the name is derived from a repo URL, truncate or hash the long portion (e.g. take a sha256 prefix) and keep it within the 64-byte identifier limit.
- Verify the value being passed is the short database name, not the full remote URL or path.
Example fix
// before remoteURL := "https://doltremoteapi.dolthub.com/my-very-long-organization-name/my-extremely-long-repository-name" store, err := dolt.BootstrapFromRemoteWithDB(ctx, remoteURL, "workdb") // after dbName := "my-org-my-repo" // <= 64 chars, matches validDatabasePattern store, err := dolt.BootstrapFromRemoteWithDB(ctx, "https://doltremoteapi.dolthub.com/my-org/my-repo", dbName)
Defensive patterns
Strategy: validation
Validate before calling
func validDBName(name string) bool { return len(name) > 0 && len(name) <= 64 }
if !validDBName(dbName) { return fmt.Errorf("db name %q must be 1-64 chars", dbName) } Type guard
func isShortIdentifier(s string) bool { return len(s) <= 64 } Prevention
- Derive database names from repo slugs by truncating to 64 bytes at creation time, not at call time.
- Centralize database-name generation in one helper used by all bootstrap calls.
- Validate configured names at config-load/startup rather than inside storage calls.
When it happens
Trigger: Calling BootstrapFromRemoteWithDB, openServerConnection, or the anonymous caller (connection setup) with a remote URL/org-repo slug or database argument whose length exceeds 64 characters.
Common situations: Deriving a database name from a long GitHub repo URL or org/repo path; embedding timestamps or UUID suffixes into already-long names; configuring a remote like 'https://doltremoteapi.dolthub.com/very-long-org/very-long-repository-name' producing a name over the limit.
Related errors
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/7c46c3d6294269ba.
Report an issue: GitHub.