multica-ai/multica · error

create label: %w

Error message

create label: %w

What it means

Wraps a failed POST /api/labels during `multica label create`. The request body carries {name, color}; the wrapped error exposes the server's rejection reason — most commonly a duplicate label name in the workspace, validation of the color format, auth, or transport failure.

Source

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

	color, _ := cmd.Flags().GetString("color")
	if name == "" {
		return fmt.Errorf("--name is required")
	}
	if color == "" {
		return fmt.Errorf("--color is required (e.g. #3b82f6)")
	}

	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}
	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	body := map[string]any{"name": name, "color": color}
	var result map[string]any
	if err := client.PostJSON(ctx, "/api/labels", body, &result); err != nil {
		return fmt.Errorf("create 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 runLabelUpdate(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check for an existing label first: `multica label list` and match by name; update instead of create if present
  2. Make setup scripts idempotent (skip or rename on conflict)
  3. Use #RRGGBB hex colors as suggested by the create-time validation hint
  4. Re-login on 401; retry once on transient network errors

Example fix

# before (fails when 'bug' already exists)
multica label create --name bug --color #3b82f6
# after (update the existing label instead)
multica label update bug --color #3b82f6
Defensive patterns

Strategy: try-catch

Validate before calling

# bash: idempotent create — only create when absent
multica label list --output json | jq -e --arg n "$NAME" '.[] | select(.name == $n)' >/dev/null \
  || multica label create --name "$NAME" --color "$COLOR"

Try / catch

if err := client.PostJSON(ctx, "/api/labels", body, &result); err != nil {
	if isConflict(err) { /* name exists: switch to update */ }
	return fmt.Errorf("create label: %w", err)
}

Prevention

When it happens

Trigger: Creating a label whose name already exists in the workspace (uniqueness conflict); malformed color string rejected server-side; 401 expired token; server 5xx or network failure.

Common situations: Re-running a setup script that is not idempotent; team members creating the same label name; non-hex color input.

Related errors


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