gastownhall/beads · error
schema: capture fresh-bootstrap identity: database is %q, wa
Error message
schema: capture fresh-bootstrap identity: database is %q, want %q
What it means
After the identity probe, the library checks that the session's current database (DATABASE()) equals the database name the caller said it just created. A mismatch means the pinned session is attached to a different database than expected, so capture refuses to issue reset authority for the wrong target.
Source
Thrown at internal/storage/schema/lock.go:120
conn *sql.Conn,
endpoint string,
expectedDatabase string,
) (*FreshBootstrapHealCapability, error) {
if endpoint == "" {
return nil, errors.New("schema: capture fresh-bootstrap identity: empty endpoint")
}
if expectedDatabase == "" {
return nil, errors.New("schema: capture fresh-bootstrap identity: empty database name")
}
var databaseName, serverUUID, initialHead string
if err := conn.QueryRowContext(ctx,
"SELECT DATABASE(), @@server_uuid, DOLT_HASHOF('HEAD')",
).Scan(&databaseName, &serverUUID, &initialHead); err != nil {
return nil, fmt.Errorf("schema: capture fresh-bootstrap identity: %w", err)
}
if databaseName != expectedDatabase {
return nil, fmt.Errorf("schema: capture fresh-bootstrap identity: database is %q, want %q", databaseName, expectedDatabase)
}
if serverUUID == "" {
return nil, errors.New("schema: capture fresh-bootstrap identity: empty server UUID")
}
if initialHead == "" {
return nil, errors.New("schema: capture fresh-bootstrap identity: empty initial HEAD")
}
var commitCount, dirtyCount int
if err := conn.QueryRowContext(ctx, "SELECT COUNT(*) FROM dolt_log").Scan(&commitCount); err != nil {
return nil, fmt.Errorf("schema: verify fresh-bootstrap history: %w", err)
}
if commitCount != 1 {
return nil, fmt.Errorf("schema: verify fresh-bootstrap history: got %d commits, want 1", commitCount)
}
if err := conn.QueryRowContext(ctx, "SELECT COUNT(*) FROM dolt_status").Scan(&dirtyCount); err != nil {
return nil, fmt.Errorf("schema: verify fresh-bootstrap working set: %w", err)
}View on GitHub (pinned to 71377f2769)
Solutions
- Make the expectedDatabase argument exactly match the database the connection is attached to (DSN db or explicit USE).
- Ensure the locked preparation runs `USE \`<db>\`` after CREATE DATABASE before capture.
- Check database-name case matches the server's (Linux Dolt servers are case-sensitive).
- Log DATABASE() alongside your configured name to spot config drift.
Example fix
// before schema.CaptureFreshBootstrapHealCapability(ctx, conn, endpoint, "Beads") // db is "beads" // after schema.CaptureFreshBootstrapHealCapability(ctx, conn, endpoint, cfg.DatabaseName) // exact name used in DSN/CREATE DATABASE
Defensive patterns
Strategy: validation
Validate before calling
var current string
if err := conn.QueryRowContext(ctx, "SELECT DATABASE()").Scan(¤t); err != nil { return err }
if current != dbName {
return fmt.Errorf("session on %q, want %q — add USE or fix DSN", current, dbName)
} Try / catch
cap, err := schema.CaptureFreshBootstrapHealCapability(ctx, conn, endpoint, dbName)
if err != nil && strings.Contains(err.Error(), "database is") {
// wrong database selected: fix DSN/USE and retry
} Prevention
- Use a DSN that names the database and pass that same name as expectedDatabase.
- Issue `USE \`db\`` in locked preparation right after CREATE DATABASE.
- Match database-name case exactly (Linux servers are case-sensitive).
- Centralize the database name in one config value.
When it happens
Trigger: Calling CaptureFreshBootstrapHealCapability with expectedDatabase not matching the session's selected database — e.g. the DSN names database A while the caller passes B, or the locked preparation created one database but did not USE the one passed in.
Common situations: Config mistakes where the DSN database differs from the configured beads database name; a preparation hook that CREATE DATABASE'd but forgot `USE`; case-sensitivity differences in database names on Linux servers.
Related errors
- failed to open database: %w Hint: %s
- schema: capture fresh-bootstrap identity: %w
- dolt directory is required
- ErrTransaction
- ErrQuery
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/00ddaba8400756ce.
Report an issue: GitHub.