{"record":{"id":"7c420850a2856786","repo":"multica-ai/multica","slug":"read-file-s-w","errorCode":null,"errorMessage":"read file %s: %w","messagePattern":"read file (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_attachment.go","lineNumber":83,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\ttaskID, _ := cmd.Flags().GetString(\"task\")\n\tif taskID == \"\" {\n\t\ttaskID = client.TaskID\n\t}\n\tif taskID == \"\" {\n\t\treturn fmt.Errorf(\"no chat task in context: run inside a chat task (MULTICA_TASK_ID set) or pass --task <id>\")\n\t}\n\n\tpath := args[0]\n\tif isHTTPURL(path) {\n\t\treturn fmt.Errorf(\"upload accepts a local file path, not a URL: %s\", path)\n\t}\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read file %s: %w\", path, err)\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), cli.AtLeastAPITimeout(60*time.Second))\n\tdefer cancel()\n\n\tatt, err := client.UploadChatAttachment(ctx, data, path, taskID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"upload attachment: %w\", err)\n\t}\n\n\tfilename := filepath.Base(path)\n\t// Escape markdown label metacharacters in the filename so a name like\n\t// `report[v2].pdf` does not truncate the snippet's label. Files render as a\n\t// block-level attachment card via `!file[...]( )`; images render inline via\n\t// `![...]( )`.\n\tlabel := escapeMarkdownLabel(filename)\n\tmarkdown := fmt.Sprintf(\"!file[%s](%s)\", label, att.MarkdownURL)\n\tif strings.HasPrefix(att.ContentType, \"image/\") {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_attachment.go#L65-L101","documentation":"The attachment upload command reads the local file with os.ReadFile before sending it. This error wraps the underlying os.ReadFile failure (the %w preserves the OS error: no such file, permission denied, is a directory, etc.).","triggerScenarios":"Passing a path that does not exist, a directory instead of a file, or a file the current user cannot read (ownership/permission mismatch, restrictive umask, read-only mount).","commonSituations":"Typos or wrong relative paths (command run from a different cwd than assumed); files created by another user or root; paths with unexpanded ~ or env vars; files on an unplugged network mount.","solutions":["Verify the file exists and is readable: `ls -l <path>` / `test -r <path>`","Use an absolute path or expand ~ explicitly (`~/x` is not expanded by Go's os.ReadFile; use $HOME/x)","Fix permissions if needed: `chmod +r <file>` or run with appropriate privileges","Confirm you passed a file, not a directory"],"exampleFix":"# before\nmultica attachment upload report.pdf   # run from wrong cwd\n\n# after\nmultica attachment upload \"$(pwd)/report.pdf\"\n# guard in shell:\n[ -r \"$f\" ] || { echo \"missing or unreadable: $f\" >&2; exit 1; }","handlingStrategy":"validation","validationCode":"# shell pre-check\n[ -f \"$path\" ] && [ -r \"$path\" ] || { echo \"missing/unreadable: $path\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths (expand $HOME yourself) when scripting the CLI","Check existence and readability before invoking upload to give clearer errors"],"tags":["cli","attachment","filesystem","user-input"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}