{"record":{"id":"6ea7c6684f2ef000","repo":"multica-ai/multica","slug":"read-file-for-s-w","errorCode":null,"errorMessage":"read file for --%s: %w","messagePattern":"read file for --(.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_issue.go","lineNumber":78,"sourceCode":"\n\tif useStdin {\n\t\tdata, err := io.ReadAll(os.Stdin)\n\t\tif err != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\"read stdin for --%s: %w\", stdinFlag, err)\n\t\t}\n\t\tbody := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif body == \"\" {\n\t\t\treturn \"\", false, fmt.Errorf(\"stdin content for --%s is empty\", stdinFlag)\n\t\t}\n\t\treturn body, true, nil\n\t}\n\tif filePath != \"\" {\n\t\tif err := ensureFileFlagWithinWorkdir(cmd, fileFlag, flagName, filePath); err != nil {\n\t\t\treturn \"\", false, err\n\t\t}\n\t\tdata, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\"read file for --%s: %w\", fileFlag, err)\n\t\t}\n\t\tbody := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif body == \"\" {\n\t\t\treturn \"\", false, fmt.Errorf(\"file content for --%s is empty\", fileFlag)\n\t\t}\n\t\treturn body, true, nil\n\t}\n\tif inline == \"\" {\n\t\treturn \"\", false, nil\n\t}\n\treturn util.UnescapeBackslashEscapes(inline), true, nil\n}\n\n// ensureFileFlagWithinWorkdir fails closed when a --<name>-file path resolves\n// outside the current working directory, unless --allow-external-file is set.\n//\n// Agent task workdirs are isolated per profile and per task; machine-shared\n// scratch paths like /tmp are not. MUL-4252 traced a cross-environment context","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_issue.go#L60-L96","documentation":"Returned by the shared text-source helper when os.ReadFile fails for a --flag-file variant. The %s names the file flag and %w wraps the underlying path error (not found, permission denied, is-a-directory, etc.). Note the path must also pass ensureFileFlagWithinWorkdir first, so it is already constrained to the working directory.","triggerScenarios":"Using --flag-file with a nonexistent path, an unreadable file (bad permissions), or a directory. The reachability-within-workdir check passed, so the path resolved legally but the OS read itself failed.","commonSituations":"Relative paths resolved from a different cwd than expected; files deleted between command construction and execution; permission mismatches when running under a different user or container; typos in the filename.","solutions":["Check the wrapped error for the OS cause; verify the path exists and is a readable regular file (ls -l, test -f && test -r)","Use a path relative to the current working directory (the helper enforces workdir containment) or an absolute path inside it","Fix permissions if reading fails with EACCES (chmod/chown or run as a user with read access)","If the file is generated by an earlier step, verify that step succeeded before this command runs"],"exampleFix":"# before\nmultica issue create --title \"T\" --description-file ./desc.txt\n# error: read file for --description-file: open ./desc.txt: no such file or directory\n\n# after\nls -l ./desc.txt  # confirm it exists and is readable\nmultica issue create --title \"T\" --description-file ./desc.txt","handlingStrategy":"validation","validationCode":"# bash: verify readability and workdir containment before --*-file\n[[ -f \"$DESC_FILE\" && -r \"$DESC_FILE\" ]] || { echo \"missing/unreadable: $DESC_FILE\" >&2; exit 1; }\nmultica issue create --title \"$t\" --description-file \"$DESC_FILE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check file existence and permissions (test -f, test -r) before invoking file flags","Remember the helper restricts file paths to the current working directory — run the CLI from the directory containing the file"],"tags":["cli","filesystem","io","flags"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}