{"record":{"id":"a4e07ff81c1635df","repo":"gastownhall/beads","slug":"failed-to-check-remote-s-w","errorCode":null,"errorMessage":"failed to check remote %s: %w","messagePattern":"failed to check remote (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":4988,"sourceCode":"type CommitInfo = storage.CommitInfo\n\n// HistoryEntry represents a row from dolt_history_* table\ntype HistoryEntry struct {\n\tCommitHash string\n\tCommitter  string\n\tCommitDate time.Time\n\t// Issue data at that commit\n\tIssueData map[string]interface{}\n}\n\n// HasRemote checks if a Dolt remote with the given name exists.\nfunc (s *DoltStore) HasRemote(ctx context.Context, name string) (bool, error) {\n\tvar count int\n\terr := s.queryRowContext(ctx, func(row *sql.Row) error {\n\t\treturn row.Scan(&count)\n\t}, \"SELECT COUNT(*) FROM dolt_remotes WHERE name = ?\", name)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to check remote %s: %w\", name, err)\n\t}\n\treturn count > 0, nil\n}\n\n// AddRemote adds a Dolt remote\nfunc (s *DoltStore) AddRemote(ctx context.Context, name, url string) error {\n\t_, err := s.db.ExecContext(ctx, \"CALL DOLT_REMOTE('add', ?, ?)\", name, url)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to add remote %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// Status returns the current Dolt status (staged/unstaged changes)\nfunc (s *DoltStore) Status(ctx context.Context) (*DoltStatus, error) {\n\treturn versioncontrolops.Status(ctx, s.db)\n}\n","sourceCodeStart":4970,"sourceCodeEnd":5006,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L4970-L5006","documentation":"HasRemote checks dolt_remotes for a named remote via a parameterized COUNT(*) query. This error wraps a failure of that query/scan — not 'remote not found' (that returns false, nil), but an actual failure executing or reading the result. Most commonly the dolt_remotes system table is unreadable because the database isn't a valid Dolt database or the query/scan failed for connection or context reasons.","triggerScenarios":"Calling HasRemote(ctx, name) when queryRowContext's row.Scan fails: ctx cancelled mid-query, Dolt server unavailable, session error reading dolt_remotes, or a scan type mismatch.","commonSituations":"Running against a non-Dolt database or corrupted .dolt directory; server down; checking remotes with an expired request context inside a longer operation.","solutions":["Verify the database is a Dolt database (.dolt directory present, dolt sql-server running).","Run the query manually (SELECT COUNT(*) FROM dolt_remotes WHERE name='<name>') to see the underlying error.","Check ctx deadline and connection health (db.Ping).","Retry — transient connection errors resolve after pool recycling.","If remotes were manipulated externally, verify dolt_remotes integrity (dolt remotes list)."],"exampleFix":"// before\nhas, err := store.HasRemote(ctx, \"origin\") // ctx from an already-timed-out request\n// after\nqctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\ndefer cancel()\nhas, err := store.HasRemote(qctx, \"origin\")","handlingStrategy":"validation","validationCode":"func validateDoltDB(db *sql.DB, ctx context.Context) error {\n    var name string\n    return db.QueryRowContext(ctx, \"SELECT DATABASE()\").Scan(&name) // fails fast if not a Dolt db/session\n}\n// also: file .dolt directory exists before opening the store","typeGuard":null,"tryCatchPattern":"has, err := store.HasRemote(ctx, \"origin\")\nif err != nil {\n    var drivenErr error\n    if errors.As(err, &drivenErr) && strings.Contains(err.Error(), \"dolt_remotes\") {\n        return fmt.Errorf(\"not a Dolt database or dolt_remotes unreadable: %w\", err)\n    }\n    return err\n}","preventionTips":["Confirm the target directory is a Dolt database before opening the store","Use short, dedicated contexts for metadata checks","Distinguish (false, nil) = remote absent from (false, err) = check failed","Run dolt fsck / dolt remotes list when metadata queries start failing"],"tags":["dolt","remote","query","database"],"backgroundTag":"remote-check-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}