{"record":{"id":"8fc9f91c66adbf7a","repo":"gastownhall/beads","slug":"list-tags-w","errorCode":null,"errorMessage":"list tags: %w","messagePattern":"list tags: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/remoterefs.go","lineNumber":57,"sourceCode":"\t\treturn nil, err\n\t}\n\tvar pruned []string\n\tfor _, name := range refs {\n\t\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BRANCH('-D', '-r', ?)\", name); err != nil {\n\t\t\treturn pruned, fmt.Errorf(\"delete remote-tracking ref %s: %w\", name, err)\n\t\t}\n\t\tpruned = append(pruned, name)\n\t}\n\treturn pruned, nil\n}\n\n// ListTags returns the names of all Dolt tags, sorted by name. Tags anchor\n// history the same way remote-tracking refs do, but they are user-created, so\n// callers should surface them rather than delete them.\nfunc ListTags(ctx context.Context, db DBConn) ([]string, error) {\n\trows, err := db.QueryContext(ctx, \"SELECT tag_name FROM dolt_tags ORDER BY tag_name\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"list tags: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tvar tags []string\n\tfor rows.Next() {\n\t\tvar name string\n\t\tif err := rows.Scan(&name); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"scan tag: %w\", err)\n\t\t}\n\t\ttags = append(tags, name)\n\t}\n\treturn tags, rows.Err()\n}\n","sourceCodeStart":39,"sourceCodeEnd":71,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/remoterefs.go#L39-L71","documentation":"ListTags queries the dolt_tags system table to enumerate Dolt tag names, sorted by name. This error wraps a failure of the initial QueryContext — the tag listing query itself failed (connection issue, server error, unavailable system table, or cancelled context). Tags are user-created history anchors, so this failure blocks any caller that needs to surface or protect them.","triggerScenarios":"Calling ListTags when db.QueryContext(ctx, \"SELECT tag_name FROM dolt_tags ORDER BY name\") fails: broken/closed connection, Dolt server error, dolt_tags table unavailable on old Dolt engines, or an already-cancelled ctx.","commonSituations":"Database connection lost mid-session; running against a Dolt version without dolt_tags; context deadline exceeded before query execution; insufficient server permissions to read system tables.","solutions":["Unwrap the error (%w) to find the root cause: reconnect to the database for connection errors.","If the context was cancelled or timed out, retry with a fresh context.","Verify Dolt version supports dolt_tags; upgrade the driver/server if the table is missing.","Ensure the DBConn is open and healthy before calling (ping first)."],"exampleFix":"// before\nctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)\ntags, err := versioncontrolops.ListTags(ctx, db) // fails: ctx already expired\n// after\ndeadline := time.Now().Add(5 * time.Second)\nctx, cancel := context.WithTimeout(context.Background(), time.Until(deadline))\ntags, err := versioncontrolops.ListTags(ctx, db)","handlingStrategy":"try-catch","validationCode":"if err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"database unavailable before ListTags: %w\", err)\n}","typeGuard":"func isCtxCancelled(err error) bool {\n    return errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)\n}","tryCatchPattern":"tags, err := versioncontrolops.ListTags(ctx, db)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        // retry with longer-lived context\n    }\n    return fmt.Errorf(\"tag listing failed: %w\", err)\n}","preventionTips":["Ping the database before tag operations.","Use a context timeout sized for metadata queries.","Verify the Dolt engine supports dolt_tags (keep driver/server updated).","Unwrap the error to distinguish connection, permission, and context failures."],"tags":["dolt","sql","database"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}