{"record":{"id":"6cf5524a407922eb","repo":"gastownhall/beads","slug":"table-name-cannot-be-empty","errorCode":null,"errorMessage":"table name cannot be empty","messagePattern":"table name cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/history.go","lineNumber":45,"sourceCode":"// ValidateDatabaseName checks if a database name is safe to use in queries.\n// Prevents SQL injection via backtick escaping in CREATE DATABASE statements.\nfunc ValidateDatabaseName(name string) error {\n\tif name == \"\" {\n\t\treturn fmt.Errorf(\"database name cannot be empty\")\n\t}\n\tif len(name) > 64 {\n\t\treturn fmt.Errorf(\"database name too long\")\n\t}\n\tif !validDatabasePattern.MatchString(name) {\n\t\treturn fmt.Errorf(\"invalid database name: %s\", name)\n\t}\n\treturn nil\n}\n\n// validateTableName checks if a table name is safe to use in queries\nfunc validateTableName(table string) error {\n\tif table == \"\" {\n\t\treturn fmt.Errorf(\"table name cannot be empty\")\n\t}\n\tif len(table) > 64 {\n\t\treturn fmt.Errorf(\"table name too long\")\n\t}\n\tif !validTablePattern.MatchString(table) {\n\t\treturn fmt.Errorf(\"invalid table name: %s\", table)\n\t}\n\treturn nil\n}\n\n// issueHistory represents an issue at a specific point in history\ntype issueHistory struct {\n\tIssue      *types.Issue\n\tCommitHash string\n\tCommitter  string\n\tCommitDate time.Time\n}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/history.go#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the table name passed to the querying function is a non-empty, valid table identifier; fix the caller that is passing \"\".","Check that package-level table name constants are initialized and not shadowed by empty variables.","Add an early check in your own wrapper to fail with context naming which config field was empty."],"exampleFix":"// before\nvar tableName string // accidentally left empty\nrows, err := store.QueryHistory(ctx, issueID, tableName)\n// after\ntableName := \"issues\"\nif tableName == \"\" { return fmt.Errorf(\"table name not configured\") }\nrows, err := store.QueryHistory(ctx, issueID, tableName)","handlingStrategy":"validation","validationCode":"if tableName == \"\" { return fmt.Errorf(\"table name not configured\") }\n// proceed with query","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use named constants for table names instead of bare string variables that can default to \"\".","Fail fast at startup if configured table names are empty.","Avoid optional table-name parameters that default to empty string; make them required."],"tags":["validation","table-name","dolt","sql"],"backgroundTag":"empty-identifier","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}