gastownhall/beads · error

failed to search protos: %w

Error message

failed to search protos: %w

What it means

resolveProtoIDOrTitle resolves user input to a proto-molecule ID, first by ID lookup, then by searching all issues carrying the template label via s.GetIssuesByLabel. If that label search fails at the storage layer, it throws 'failed to search protos: %w'. This means the proto catalog itself could not be enumerated — distinct from 'no match found' (error 1274).

Source

Thrown at cmd/bd/template.go:274

	protoID, err := utils.ResolvePartialID(ctx, s, input)
	if err == nil {
		// Verify it's a proto (has template label)
		issue, getErr := s.GetIssue(ctx, protoID)
		if getErr == nil && issue != nil {
			labels, _ := s.GetLabels(ctx, protoID)
			for _, label := range labels {
				if label == BeadsTemplateLabel {
					return protoID, nil // Found a valid proto by ID
				}
			}
		}
		// ID resolved but not a proto - continue to title search
	}

	// Strategy 2: Search for protos by title
	protos, err := s.GetIssuesByLabel(ctx, BeadsTemplateLabel)
	if err != nil {
		return "", fmt.Errorf("failed to search protos: %w", err)
	}

	var matches []*types.Issue
	var exactMatch *types.Issue

	for _, proto := range protos {
		// Check for exact title match (case-insensitive)
		if strings.EqualFold(proto.Title, input) {
			exactMatch = proto
			break
		}
		// Check for partial title match (case-insensitive)
		if strings.Contains(strings.ToLower(proto.Title), strings.ToLower(input)) {
			matches = append(matches, proto)
		}
	}

	if exactMatch != nil {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped error (errors.Unwrap) for the underlying storage cause.
  2. Run `bd doctor` to validate database and label-index health.
  3. Retry once transient driver errors are excluded.
  4. If the label index is corrupt, re-export/re-sync the database to rebuild it.
Defensive patterns

Strategy: try-catch

Try / catch

pid, err := resolveProtoIDOrTitle(ctx, s, input)
if err != nil {
	var storageErr bool
	if strings.Contains(err.Error(), "failed to search protos") { storageErr = true }
	// distinguish storage failure from not-found/ambiguous and report accordingly
	return err
}

Prevention

When it happens

Trigger: Calling any command that resolves a proto by ID-or-title when GetIssuesByLabel(BeadsTemplateLabel) errors: label index corruption, storage/driver failure, or transaction issues during the query.

Common situations: Dolt database in a bad state after an interrupted sync; embedded driver I/O error; permission problems reading the .beads database file.

Related errors


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