gastownhall/beads · error

load wisp labels: %w

Error message

load wisp labels: %w

What it means

This error wraps a failure from `LabelUseCase().GetLabelsForWisps(ctx, allIDs)` while bulk-loading label relations for wisp-plane issues during export. The wrapper exists so the underlying storage/DB error is attributed to the 'load wisp labels' step of LoadExportRelations. It is deliberately suppressed (not returned) when the error is dberrors.IsTableNotExist, because a rig without wisp tables simply has no labels; so this error only fires for real storage failures.

Source

Thrown at cmd/bd/export_source.go:265

	if err != nil {
		return exportRelations{}, fmt.Errorf("load labels: %w", err)
	}
	mergeExportMap(rel.labels, labels)
	comments, err := s.uw.CommentUseCase().GetCommentsForIssues(ctx, allIDs)
	if err != nil {
		return exportRelations{}, fmt.Errorf("load comments: %w", err)
	}
	mergeExportMap(rel.comments, comments)
	counts, err := s.uw.CommentUseCase().GetCommentCounts(ctx, allIDs)
	if err != nil {
		return exportRelations{}, fmt.Errorf("load comment counts: %w", err)
	}
	mergeExportMap(rel.commentCounts, counts)

	wispLabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs) //nolint:forbidigo // bulk relation load; see GetLabelsForIssues above
	if err != nil {
		if !dberrors.IsTableNotExist(err) {
			return exportRelations{}, fmt.Errorf("load wisp labels: %w", err)
		}
	} else {
		mergeExportMap(rel.labels, wispLabels)
	}
	wispComments, err := s.uw.CommentUseCase().GetCommentsForWisps(ctx, allIDs)
	if err != nil {
		if !dberrors.IsTableNotExist(err) {
			return exportRelations{}, fmt.Errorf("load wisp comments: %w", err)
		}
	} else {
		mergeExportMap(rel.comments, wispComments)
	}
	wispCounts, err := s.uw.CommentUseCase().GetWispCommentCounts(ctx, allIDs)
	if err != nil {
		if !dberrors.IsTableNotExist(err) {
			return exportRelations{}, fmt.Errorf("load wisp comment counts: %w", err)
		}
	} else {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause (printed after the %w chain) — if it is a connection error, ensure the Dolt server/database backing the rig is running and reachable
  2. Run `bd doctor` (or the storage-layer doctor checks) to verify DB integrity and schema state
  3. If the wrapped error is table-not-exist related but not detected, verify dberrors.IsTableNotExist covers your driver's error; consider re-running after schema migration completes
  4. Re-run the export with a fresh context; if it was a transient cancellation or timeout, retry

Example fix

// before: export fails with opaque wrapped error
labels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs)
// after: inspect the underlying cause and fail loudly only on non-transient errors
labels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs)
if err != nil {
    if dberrors.IsTableNotExist(err) { labels = nil } else { return exportRelations{}, fmt.Errorf("load wisp labels: %w", err) }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Go has no pre-call validation for DB health; optionally ping the store first
if err := store.PingContext(ctx); err != nil {
    return fmt.Errorf("storage backend unreachable before export: %w", err)
}

Type guard

func isTableNotExist(err error) bool { return dberrors.IsTableNotExist(err) }

Try / catch

wispLabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs)
if err != nil {
    if dberrors.IsTableNotExist(err) {
        wispLabels = nil // legacy rig: no wisp plane
    } else {
        return fmt.Errorf("load wisp labels: %w", err)
    }
}

Prevention

When it happens

Trigger: Calling LoadExportRelations (via bd export) when GetLabelsForWisps returns a non-nil error that is NOT a missing-table error — e.g. Dolt connection failure, corrupted label/wisp_label table, context cancellation, or SQL error querying labels for the given wisp IDs.

Common situations: Running `bd export` against a rig whose Dolt server is down or unreachable; a partially-initialized database where the label table is corrupt or schema-migration failed; the context being cancelled mid-export (Ctrl-C or timeout); disk/IO errors on the Dolt database.

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/1e4224408efe72be. Report an issue: GitHub.