{"record":{"id":"805f6c1d5a054a04","repo":"multica-ai/multica","slug":"get-source-agent-w","errorCode":null,"errorMessage":"get source agent: %w","messagePattern":"get source agent: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent_copy.go","lineNumber":107,"sourceCode":"\tif cmd.Flags().Changed(\"max-concurrent-tasks\") {\n\t\tv, _ := cmd.Flags().GetInt32(\"max-concurrent-tasks\")\n\t\tif err := validateAgentMaxConcurrentTasksFlag(v); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmaxConcurrentTasksOverride = &v\n\t}\n\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar src map[string]any\n\tif err := client.GetJSON(ctx, \"/api/agents/\"+args[0], &src); err != nil {\n\t\treturn fmt.Errorf(\"get source agent: %w\", err)\n\t}\n\n\tsrcRuntimeID := strVal(src, \"runtime_id\")\n\n\t// Resolve the target runtime: default to the source's runtime, override\n\t// with --runtime-id. A different value is a cross-runtime fork.\n\ttargetRuntimeID := srcRuntimeID\n\tif cmd.Flags().Changed(\"runtime-id\") {\n\t\tv, _ := cmd.Flags().GetString(\"runtime-id\")\n\t\tif v == \"\" {\n\t\t\treturn fmt.Errorf(\"--runtime-id must not be empty\")\n\t\t}\n\t\ttargetRuntimeID = v\n\t}\n\tif targetRuntimeID == \"\" {\n\t\treturn fmt.Errorf(\"source agent has no runtime; pass --runtime-id to choose a target runtime\")\n\t}\n\tsameRuntime := targetRuntimeID == srcRuntimeID","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent_copy.go#L89-L125","documentation":"Thrown by `multica agent copy <id>` when the initial GET /api/agents/{id} to fetch the source agent fails. The wrapped error carries the HTTP layer cause: 404 unknown agent ID, 401/403 auth failure, connection refused to the API server, or a malformed server response. Nothing else in the copy flow runs until this succeeds.","triggerScenarios":"`multica agent copy <bad-or-deleted-id>`; CLI pointed at the wrong API base URL; expired or missing API token; API server not running or unreachable from the network.","commonSituations":"Copying an agent ID copied from a different workspace/environment; the agent was deleted between listing and copying; dev CLI pointed at prod URL or vice versa; token expired after long-lived shell session.","solutions":["Confirm the agent exists in this environment: multica agent get <id> (or agent list) and re-copy the ID","Check API connectivity and auth: verify the CLI's server URL and token configuration, retry after multica login or token refresh","If the server is down, start it / fix the base URL, then retry the copy"],"exampleFix":"# before\nmultica agent copy abc123   # stale id from another workspace\n# after\nmultica agent list --output json | jq '.[].id'\nmultica agent copy <fresh-id>","handlingStrategy":"try-catch","validationCode":"# confirm the agent exists before copying\nmultica agent get \"$AGENT_ID\" >/dev/null 2>&1 || { echo \"agent $AGENT_ID not found\" >&2; exit 1; }\nmultica agent copy \"$AGENT_ID\"","typeGuard":null,"tryCatchPattern":"In Go API clients: var src map[string]any; if err := client.GetJSON(ctx, \"/api/agents/\"+id, &src); err != nil { return fmt.Errorf(\"get source agent: %w\", err) } — inspect errors.Is/As on the wrapped HTTP error to distinguish 404 (bad ID) from 401 (auth) from network errors.","preventionTips":["Always fetch IDs from a live listing in the same environment, never from notes or other workspaces","Re-verify IDs in long-running scripts right before use","Keep CLI auth fresh; run a cheap authenticated call first to fail fast"],"tags":["cli","api","http","auth","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}