multica-ai/multica · error

update label: %w

Error message

update label: %w

What it means

Wraps a failed PUT /api/labels/{labelID} during `multica label update`. Only the provided fields (name and/or color) are sent. The wrapped error reflects the server's response: duplicate name conflict, invalid color, auth failure, or transport error.

Source

Thrown at server/cmd/multica/cmd_label.go:229

	labelRef, err := resolveLabelID(ctx, client, args[0])
	if err != nil {
		return fmt.Errorf("resolve label: %w", err)
	}

	body := map[string]any{}
	if v, _ := cmd.Flags().GetString("name"); v != "" {
		body["name"] = v
	}
	if v, _ := cmd.Flags().GetString("color"); v != "" {
		body["color"] = v
	}
	if len(body) == 0 {
		return fmt.Errorf("nothing to update — provide --name and/or --color")
	}

	var result map[string]any
	if err := client.PutJSON(ctx, "/api/labels/"+labelRef.ID, body, &result); err != nil {
		return fmt.Errorf("update label: %w", err)
	}

	output, _ := cmd.Flags().GetString("output")
	if output == "table" {
		headers := []string{"ID", "NAME", "COLOR"}
		rows := [][]string{{
			strVal(result, "id"),
			strVal(result, "name"),
			strVal(result, "color"),
		}}
		cli.PrintTable(os.Stdout, headers, rows)
		return nil
	}
	return cli.PrintJSON(os.Stdout, result)
}

func runLabelDelete(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check `multica label list` for the target name before renaming
  2. Revert or pick a unique name on a duplicate-name error
  3. Re-authenticate on 401; retry once on transient failures
  4. Re-resolve the label if it may have been deleted mid-script
Defensive patterns

Strategy: try-catch

Validate before calling

# bash: avoid rename collisions
multica label list --output json | jq -e --arg n "$NEW_NAME" '.[] | select(.name == $n)' >/dev/null \
  && { echo "name $NEW_NAME already taken" >&2; exit 2; } || true

Try / catch

if err := client.PutJSON(ctx, "/api/labels/"+id, body, &result); err != nil {
	if isConflict(err) { /* pick a unique name */ }
	if isNotFound(err) { /* re-resolve the label */ }
	return fmt.Errorf("update label: %w", err)
}

Prevention

When it happens

Trigger: Renaming a label to a name that already exists in the workspace; supplying a color the server rejects; 401/403; label deleted between resolve and PUT (race); network/server failure.

Common situations: Rename collisions with existing labels; stale credentials; concurrent label edits in a team.

Related errors


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