{"record":{"id":"cc2c75beb74fe5e3","repo":"larksuite/cli","slug":"cannot-read-file-q-w","errorCode":null,"errorMessage":"cannot read file %q: %w","messagePattern":"cannot read file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmdutil/resolve.go","lineNumber":105,"sourceCode":"\t\treturn nil, fmt.Errorf(\"file input is not available in this context\")\n\t}\n\tf, err := fileIO.Open(path)\n\tif err != nil {\n\t\treturn nil, wrapInputFileError(path, err)\n\t}\n\tdefer f.Close()\n\tdata, err := io.ReadAll(f)\n\tif err != nil {\n\t\treturn nil, wrapInputFileError(path, err)\n\t}\n\treturn data, nil\n}\n\nfunc wrapInputFileError(path string, err error) error {\n\tif errors.Is(err, fileio.ErrPathValidation) {\n\t\treturn fmt.Errorf(\"invalid file path %q: %w\", path, err)\n\t}\n\treturn fmt.Errorf(\"cannot read file %q: %w\", path, err)\n}\n","sourceCodeStart":87,"sourceCodeEnd":107,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/cmdutil/resolve.go#L87-L107","documentation":"wrapInputFileError's fallback branch wraps any FileIO.Open or read error that is not ErrPathValidation as \"cannot read file %q: %w\". Typical causes are file-not-found, permission denied, or a read failure — the wrapped cause identifies which.","triggerScenarios":"Using --body @path where the file does not exist, lacks read permission, or the underlying reader fails after Open. Any non-validation error from ReadInputFile's open/read path lands here.","commonSituations":"Typo in the filename; file deleted between generation and use; running in a sidecar/container that lacks the file; permission changes; relative path resolved against an unexpected root.","solutions":["Check the wrapped cause: not-found → fix the path; permission-denied → fix permissions","Run ls/stat on the exact path relative to the FileIO workspace root","Create/regenerate the file before invoking the command","Fall back to piping content via stdin (\"-\") if the file is inaccessible"],"exampleFix":"// before\nlark-cli cmd --body @paylaod.json   # typo\n// after\nlark-cli cmd --body @payload.json","handlingStrategy":"try-catch","validationCode":"# shell pre-checks\n[ -e \"$f\" ] || { echo \"missing: $f\"; exit 1; }\n[ -r \"$f\" ] || { echo \"unreadable: $f\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, fs.ErrNotExist) { fmt.Fprintf(os.Stderr, \"no such file: %v\\n\", err) }\n    else if errors.Is(err, fs.ErrPermission) { fmt.Fprintf(os.Stderr, \"permission denied: %v\\n\", err) }\n    return err\n}","preventionTips":["Stat the file (existence + readability) before invoking","Use stable, verified paths; avoid typos via tab-completion/variables","Ensure sidecar containers mount the expected files","Regenerate files in an atomic write before use"],"tags":["fileio","file-not-found","file-input"],"backgroundTag":"cannot-read-file","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}