{"record":{"id":"55e7cd3849672fa3","repo":"multica-ai/multica","slug":"get-attachment-w","errorCode":null,"errorMessage":"get attachment: %w","messagePattern":"get attachment: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_attachment.go","lineNumber":141,"sourceCode":"\t\t`]`, `\\]`,\n\t\t`(`, `\\(`,\n\t\t`)`, `\\)`,\n\t).Replace(s)\n}\n\nfunc runAttachmentDownload(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), cli.AtLeastAPITimeout(60*time.Second))\n\tdefer cancel()\n\n\t// Fetch attachment metadata (includes signed download_url).\n\tvar att map[string]any\n\tif err := client.GetJSON(ctx, \"/api/attachments/\"+args[0], &att); err != nil {\n\t\treturn fmt.Errorf(\"get attachment: %w\", err)\n\t}\n\n\tdownloadURL := strVal(att, \"download_url\")\n\tif downloadURL == \"\" {\n\t\treturn fmt.Errorf(\"attachment has no download URL\")\n\t}\n\n\tfilename := filepath.Base(strVal(att, \"filename\"))\n\tif filename == \"\" || filename == \".\" {\n\t\tfilename = args[0]\n\t}\n\n\t// Download the file content.\n\tdata, err := client.DownloadFile(ctx, downloadURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"download file: %w\", err)\n\t}\n","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_attachment.go#L123-L159","documentation":"The download command first fetches attachment metadata via GET /api/attachments/{id} using client.GetJSON. This error wraps any failure of that request: 404 for an unknown id, 401/403 for bad auth, network errors, or malformed JSON responses.","triggerScenarios":"Passing a wrong or truncated attachment id to `multica attachment download <id>`; token lacking access to the attachment's workspace; server down or unreachable; attachment deleted between listing and downloading.","commonSituations":"Copy-pasting an id with extra characters or a missing suffix; using an old token after workspace switch; scripts reusing cached ids after the attachment expired; CLI pointed at the wrong server URL.","solutions":["Double-check the attachment id (copy the full id, no surrounding markdown)","Verify auth and target server: `multica auth status` and the configured server URL","Confirm the attachment still exists (re-list attachments for the task)","Check network/proxy settings if the server is unreachable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# validate id shape before calling (non-empty, no slashes/whitespace)\ncase \"$id\" in ''|*[!A-Za-z0-9_-]*) echo \"bad attachment id: $id\" >&2; exit 1;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extract attachment ids from structured output (--output json), never by scraping text","Verify auth and server reachability (`multica auth status`) before batch downloads"],"tags":["cli","attachment","network","api","download"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}