{"record":{"id":"2ddbe556c98ffd93","repo":"multica-ai/multica","slug":"copy-agent-w","errorCode":null,"errorMessage":"copy agent: %w","messagePattern":"copy agent: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent_copy.go","lineNumber":280,"sourceCode":"\t\tbody[\"custom_env\"] = ce\n\t}\n\tif mc, ok, err := resolveMcpConfig(cmd); err != nil {\n\t\treturn err\n\t} else if ok {\n\t\tbody[\"mcp_config\"] = mc\n\t}\n\tif cmd.Flags().Changed(\"runtime-config\") {\n\t\tv, _ := cmd.Flags().GetString(\"runtime-config\")\n\t\tvar rc any\n\t\tif err := json.Unmarshal([]byte(v), &rc); err != nil {\n\t\t\treturn fmt.Errorf(\"--runtime-config must be valid JSON: %w\", err)\n\t\t}\n\t\tbody[\"runtime_config\"] = rc\n\t}\n\n\tvar result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/agents\", body, &result); err != nil {\n\t\treturn fmt.Errorf(\"copy agent: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\n\tfmt.Printf(\"Agent copied: %s (%s)\\n\", strVal(result, \"name\"), strVal(result, \"id\"))\n\treturn nil\n}\n\nfunc copiedAgentMaxConcurrentTasks(value any) (int32, bool) {\n\tnumber, ok := value.(float64)\n\tif !ok || number != math.Trunc(number) ||\n\t\tnumber < float64(agentconfig.MinMaxConcurrentTasks) ||\n\t\tnumber > float64(agentconfig.MaxMaxConcurrentTasks) {\n\t\treturn 0, false\n\t}","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent_copy.go#L262-L298","documentation":"Thrown by `multica agent copy` when the final POST /api/agents that creates the copy fails. The wrapped error exposes the server's rejection: 4xx validation errors (invalid model for the runtime, bad body fields), 401/403 auth issues, or 5xx/connection failures. All earlier local validation has passed by this point, so the cause is server-side.","triggerScenarios":"Cross-runtime copy with a --model that does not exist on the target runtime; workspace limits reached; duplicate name conflicts if the server enforces them; API version mismatch between CLI and server.","commonSituations":"Model names that differ across runtimes (the exact risk error 272 warns about); expired tokens between the GET and POST; server-side schema changes after a CLI/server version skew.","solutions":["Read the wrapped error body — it names the rejected field (e.g. unknown model)","Verify the model exists on the target runtime and re-run with a valid --model","On auth/connection failures, re-authenticate and confirm the server URL, then retry"],"exampleFix":"# before\nmultica agent copy <id> --runtime-id rt_other --model gpt-4o   # model not on that runtime\n# after\nmultica agent copy <id> --runtime-id rt_other --model <model-listed-for-runtime>","handlingStrategy":"try-catch","validationCode":"# pre-validate the model on the target runtime before copying\nmultica runtime models \"$TARGET_RT\" --output json | jq -e --arg m \"$MODEL\" 'map(.id) | index($m)' >/dev/null \\\n  || { echo \"model $MODEL not on runtime $TARGET_RT\" >&2; exit 1; }\nmultica agent copy \"$AGENT_ID\" --runtime-id \"$TARGET_RT\" --model \"$MODEL\"","typeGuard":null,"tryCatchPattern":"In Go: var result map[string]any; if err := client.PostJSON(ctx, \"/api/agents\", body, &result); err != nil { return fmt.Errorf(\"copy agent: %w\", err) } — unwrap the HTTP error and branch on status: 4xx means fix the body (model/name fields), 401 re-auth, 5xx/network retry with backoff.","preventionTips":["Verify model names exist on the target runtime before cross-runtime copies","Keep CLI and server versions in sync to avoid schema skew","Surface the wrapped error body in scripts — it names the rejected field"],"tags":["cli","api","http","validation","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}