gastownhall/beads · error

failed to resolve %s: %w

Error message

failed to resolve %s: %w

What it means

Wraps utils.ResolvePartialID failure for the DUPLICATE argument in 'bd duplicate <id> --duplicate-of <canonical>'. The partial/prefix ID supplied could not be resolved to exactly one issue in the store — typically because it is ambiguous, malformed, or no matching issue exists. The command aborts before touching any issues.

Source

Thrown at cmd/bd/duplicate.go:82

	CheckReadonly("duplicate")

	evt := metrics.NewCommandEvent("duplicate")
	defer func() {
		if c := metrics.Global(); c != nil {
			c.CloseEventAndAdd(evt)
		}
	}()

	ctx := getRootContext()
	store := getStore()
	actor := getActor()

	// Resolve partial IDs
	var duplicateID, canonicalID string
	var err error
	duplicateID, err = utils.ResolvePartialID(ctx, store, args[0])
	if err != nil {
		return fmt.Errorf("failed to resolve %s: %w", args[0], err)
	}
	canonicalID, err = utils.ResolvePartialID(ctx, store, duplicateOf)
	if err != nil {
		return fmt.Errorf("failed to resolve %s: %w", duplicateOf, err)
	}

	if duplicateID == canonicalID {
		return fmt.Errorf("cannot mark an issue as duplicate of itself")
	}

	// Verify canonical issue exists
	var canonical *types.Issue
	canonical, err = store.GetIssue(ctx, canonicalID)
	if err != nil || canonical == nil {
		return fmt.Errorf("canonical issue not found: %s", canonicalID)
	}

	// Add a "duplicates" dependency edge (duplicate → canonical)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run `bd list` or `bd show <prefix>` to find the correct full issue ID
  2. Use a longer prefix so ResolvePartialID matches exactly one issue
  3. Confirm you are in the right repo/database containing the issue
  4. If the issue was deleted, recreate it or pick the correct duplicate candidate

Example fix

// before
$ bd duplicate bd-1 --duplicate-of bd-42
Error: failed to resolve bd-1: ambiguous prefix matches 3 issues
// after
$ bd duplicate bd-123 --duplicate-of bd-42
Defensive patterns

Strategy: validation

Validate before calling

fullID, err := utils.ResolvePartialID(ctx, store, args[0])
if err != nil {
    fmt.Fprintf(os.Stderr, "duplicate target %q not found; run bd list to get exact IDs\n", args[0])
    os.Exit(1)
}

Try / catch

dupID, err := utils.ResolvePartialID(ctx, store, args[0])
if err != nil {
    var notFound *NotFoundError
    if errors.As(err, &notFound) { /* prompt user for correct ID */ }
    return err
}

Prevention

When it happens

Trigger: Calling `bd duplicate <bad-id>` where the first positional argument is a typo, a full ID that doesn't exist, an ambiguous prefix matching multiple issues, or an empty/invalid ID string.

Common situations: Typing a prefix too short to be unique (e.g. 'bd-1' matching bd-10, bd-12...); referencing an issue from another repo/database; the issue was deleted; copy-pasting an ID from a different tracker.

Related errors


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