multica-ai/multica · error

resolve %s: %w

Error message

resolve %s: %w

What it means

Wrapper error from resolveIDByPrefix that contextualizes a normalizeUUIDPrefix failure with the resource kind ("resolve label: ..."). It propagates the underlying too-short or non-hex prefix error while telling the user which resource resolution failed.

Source

Thrown at server/cmd/multica/cmd_id_resolver.go:87

	return prefix, nil
}

func compactUUID(id string) string {
	return strings.ToLower(strings.ReplaceAll(strings.TrimSpace(id), "-", ""))
}

func resolveIDByPrefix(ctx context.Context, client *cli.APIClient, kind, input string, fetch func(context.Context, *cli.APIClient) ([]idCandidate, error)) (resolvedID, error) {
	trimmed := strings.TrimSpace(input)
	if trimmed == "" {
		return resolvedID{}, fmt.Errorf("%s id is required", kind)
	}
	if uuidRegexp.MatchString(trimmed) {
		return resolvedID{ID: trimmed, Display: trimmed}, nil
	}

	prefix, err := normalizeUUIDPrefix(trimmed)
	if err != nil {
		return resolvedID{}, fmt.Errorf("resolve %s: %w", kind, err)
	}

	candidates, err := fetch(ctx, client)
	if err != nil {
		return resolvedID{}, fmt.Errorf("resolve %s: %w", kind, err)
	}

	matches := make([]idCandidate, 0, 1)
	for _, c := range candidates {
		if c.ID == "" {
			continue
		}
		if strings.HasPrefix(compactUUID(c.ID), prefix) {
			matches = append(matches, c)
		}
	}

	switch len(matches) {

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Read the wrapped message after the colon — it states the exact format problem — and fix the id accordingly
  2. Pass the full UUID obtained from the list command with --full-id
  3. Validate ids in scripts before invoking the CLI (length >= 4, hex-only after removing dashes)

Example fix

# before
multica label rm "zz"
# error: resolve label: expected a full UUID or at least 4 hex characters, got "zz"

# after
multica label rm "a1b2c3"
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-normalize exactly like the CLI does to catch format errors early
if _, err := normalizeUUIDPrefix(input); err != nil {
    return fmt.Errorf("fix id %q before calling the CLI: %w", input, err)
}

Try / catch

// In Go code wrapping the CLI: unwrap with errors.Is/As to distinguish
// prefix-format failures from fetch failures, and surface the kind context.
if err := resolveIDByPrefix(ctx, client, kind, input, fetch); err != nil {
    var formatErr *PrefixFormatError
    if errors.As(err, &formatErr) {
        // user-input problem: prompt for a corrected id
    } else {
        // transport/server problem: retry or report connectivity
    }
}

Prevention

When it happens

Trigger: Any prefix resolution where the raw input fails normalizeUUIDPrefix: fewer than 4 hex chars after dash-stripping, or non-hex characters. The wrapped error is one of the "expected a full UUID or at least N hex characters" or "only hex characters" messages.

Common situations: Same as the underlying prefix format errors: truncated ids, wrong-format keys, or values with stray characters; the kind prefix helps identify which of several id arguments was malformed.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/dcee4643bc464ca6. Report an issue: GitHub.