gastownhall/beads · error

list tags: %w

Error message

list tags: %w

What it means

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.

Source

Thrown at internal/storage/versioncontrolops/remoterefs.go:57

		return nil, err
	}
	var pruned []string
	for _, name := range refs {
		if _, err := db.ExecContext(ctx, "CALL DOLT_BRANCH('-D', '-r', ?)", name); err != nil {
			return pruned, fmt.Errorf("delete remote-tracking ref %s: %w", name, err)
		}
		pruned = append(pruned, name)
	}
	return pruned, nil
}

// ListTags returns the names of all Dolt tags, sorted by name. Tags anchor
// history the same way remote-tracking refs do, but they are user-created, so
// callers should surface them rather than delete them.
func ListTags(ctx context.Context, db DBConn) ([]string, error) {
	rows, err := db.QueryContext(ctx, "SELECT tag_name FROM dolt_tags ORDER BY tag_name")
	if err != nil {
		return nil, fmt.Errorf("list tags: %w", err)
	}
	defer rows.Close()

	var tags []string
	for rows.Next() {
		var name string
		if err := rows.Scan(&name); err != nil {
			return nil, fmt.Errorf("scan tag: %w", err)
		}
		tags = append(tags, name)
	}
	return tags, rows.Err()
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Unwrap the error (%w) to find the root cause: reconnect to the database for connection errors.
  2. If the context was cancelled or timed out, retry with a fresh context.
  3. Verify Dolt version supports dolt_tags; upgrade the driver/server if the table is missing.
  4. Ensure the DBConn is open and healthy before calling (ping first).

Example fix

// before
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
tags, err := versioncontrolops.ListTags(ctx, db) // fails: ctx already expired
// after
deadline := time.Now().Add(5 * time.Second)
ctx, cancel := context.WithTimeout(context.Background(), time.Until(deadline))
tags, err := versioncontrolops.ListTags(ctx, db)
Defensive patterns

Strategy: try-catch

Validate before calling

if err := db.PingContext(ctx); err != nil {
    return fmt.Errorf("database unavailable before ListTags: %w", err)
}

Type guard

func isCtxCancelled(err error) bool {
    return errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)
}

Try / catch

tags, err := versioncontrolops.ListTags(ctx, db)
if err != nil {
    if errors.Is(err, context.DeadlineExceeded) {
        // retry with longer-lived context
    }
    return fmt.Errorf("tag listing failed: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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