gastownhall/beads · error

table name cannot be empty

Error message

table name cannot be empty

What it means

validateTableName rejects empty table names before they are interpolated into queries such as dolt_history select statements. An empty table name would produce a confusing SQL syntax error server-side, so this is caught client-side with a clear message. It is an internal guard on the query-building path.

Source

Thrown at internal/storage/dolt/history.go:45

// 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)
	}
	return nil
}

// issueHistory represents an issue at a specific point in history
type issueHistory struct {
	Issue      *types.Issue
	CommitHash string
	Committer  string
	CommitDate time.Time
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Ensure the table name passed to the querying function is a non-empty, valid table identifier; fix the caller that is passing "".
  2. Check that package-level table name constants are initialized and not shadowed by empty variables.
  3. Add an early check in your own wrapper to fail with context naming which config field was empty.

Example fix

// before
var tableName string // accidentally left empty
rows, err := store.QueryHistory(ctx, issueID, tableName)
// after
tableName := "issues"
if tableName == "" { return fmt.Errorf("table name not configured") }
rows, err := store.QueryHistory(ctx, issueID, tableName)
Defensive patterns

Strategy: validation

Validate before calling

if tableName == "" { return fmt.Errorf("table name not configured") }
// proceed with query

Prevention

When it happens

Trigger: Calling a history/query helper that routes through validateTableName with an empty string table argument — e.g. a table constant or config field that failed to initialize, or an empty default in a calling function.

Common situations: A struct field holding the table name left unset (zero value "") after partial initialization; renaming/migrating code so a constant is no longer passed; building queries dynamically where an optional table parameter defaulted to empty.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/6cf5524a407922eb. Report an issue: GitHub.