gastownhall/beads · error

failed to get wisp labels: %w

Error message

failed to get wisp labels: %w

What it means

getWisp successfully loaded the issue row but the follow-up s.getWispLabels(ctx, id) call failed; the label-read error is wrapped as 'failed to get wisp labels'. The whole lookup fails even though the issue itself was found, because labels are an integral part of the returned issue.

Source

Thrown at internal/storage/dolt/wisps.go:160

		return configPrefix + "-" + issue.IDPrefix
	}
	return configPrefix + "-wisp"
}

// getWisp retrieves an issue from the wisps table.
func (s *DoltStore) getWisp(ctx context.Context, id string) (*types.Issue, error) {
	s.mu.RLock()
	defer s.mu.RUnlock()
	issue, err := scanIssueFromTable(ctx, s.db, "wisps", id)
	if err != nil {
		return nil, err
	}
	if issue == nil {
		return nil, nil
	}
	labels, err := s.getWispLabels(ctx, id)
	if err != nil {
		return nil, fmt.Errorf("failed to get wisp labels: %w", err)
	}
	issue.Labels = labels
	return issue, nil
}

// getWispLabels retrieves labels from the wisp_labels table.
func (s *DoltStore) getWispLabels(ctx context.Context, issueID string) ([]string, error) {
	rows, err := s.queryContext(ctx, `SELECT label FROM wisp_labels WHERE issue_id = ? ORDER BY label`, issueID)
	if err != nil {
		return nil, wrapQueryError("get wisp labels", err)
	}
	defer rows.Close()

	var labels []string
	for rows.Next() {
		var label string
		if err := rows.Scan(&label); err != nil {
			return nil, wrapScanError("scan wisp label", err)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause to identify whether it is schema, connection, or context related
  2. Verify the wisp_labels table exists and matches the expected schema (bd doctor / migrate)
  3. Retry on transient connection errors; check DB connectivity
  4. Increase the context timeout if the label query is timing out
Defensive patterns

Strategy: validation

Validate before calling

var n int
err := db.QueryRow(`SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'wisp_labels'`).Scan(&n)
if err == nil && n == 0 {
    return fmt.Errorf("wisp_labels table missing; run migration/doctor before lookups")
}

Try / catch

issue, err := store.GetIssue(ctx, id)
if err != nil && strings.Contains(err.Error(), "failed to get wisp labels") {
    // transient or schema issue on wisp_labels — retry after checking schema
    return retryWithBackoff(func() error { _, err = store.GetIssue(ctx, id); return err })
}

Prevention

When it happens

Trigger: Any error from the wisp_labels table read during getWisp: missing wisp_labels table, driver error, context cancellation, or connection failure while fetching labels for an existing wisp.

Common situations: Older database missing the wisp_labels table after a binary upgrade; transient Dolt/connection errors; context timeout while the label query runs; schema drift on wisp_labels.

Related errors


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