{"record":{"id":"ee54dad387ac8d97","repo":"multica-ai/multica","slug":"create-label-w","errorCode":null,"errorMessage":"create label: %w","messagePattern":"create label: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_label.go","lineNumber":186,"sourceCode":"\tcolor, _ := cmd.Flags().GetString(\"color\")\n\tif name == \"\" {\n\t\treturn fmt.Errorf(\"--name is required\")\n\t}\n\tif color == \"\" {\n\t\treturn fmt.Errorf(\"--color is required (e.g. #3b82f6)\")\n\t}\n\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tbody := map[string]any{\"name\": name, \"color\": color}\n\tvar result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/labels\", body, &result); err != nil {\n\t\treturn fmt.Errorf(\"create label: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"table\" {\n\t\theaders := []string{\"ID\", \"NAME\", \"COLOR\"}\n\t\trows := [][]string{{\n\t\t\tstrVal(result, \"id\"),\n\t\t\tstrVal(result, \"name\"),\n\t\t\tstrVal(result, \"color\"),\n\t\t}}\n\t\tcli.PrintTable(os.Stdout, headers, rows)\n\t\treturn nil\n\t}\n\treturn cli.PrintJSON(os.Stdout, result)\n}\n\nfunc runLabelUpdate(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_label.go#L168-L204","documentation":"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.","triggerScenarios":"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.","commonSituations":"Re-running a setup script that is not idempotent; team members creating the same label name; non-hex color input.","solutions":["Check for an existing label first: `multica label list` and match by name; update instead of create if present","Make setup scripts idempotent (skip or rename on conflict)","Use #RRGGBB hex colors as suggested by the create-time validation hint","Re-login on 401; retry once on transient network errors"],"exampleFix":"# before (fails when 'bug' already exists)\nmultica label create --name bug --color #3b82f6\n# after (update the existing label instead)\nmultica label update bug --color #3b82f6","handlingStrategy":"try-catch","validationCode":"# bash: idempotent create — only create when absent\nmultica label list --output json | jq -e --arg n \"$NAME\" '.[] | select(.name == $n)' >/dev/null \\\n  || multica label create --name \"$NAME\" --color \"$COLOR\"","typeGuard":null,"tryCatchPattern":"if err := client.PostJSON(ctx, \"/api/labels\", body, &result); err != nil {\n\tif isConflict(err) { /* name exists: switch to update */ }\n\treturn fmt.Errorf(\"create label: %w\", err)\n}","preventionTips":["Check existence before create (or tolerate 409 by updating)","Make provisioning scripts idempotent","Use canonical hex colors"],"tags":["cli","http","labels"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}