{"record":{"id":"ee0401f39883dbe0","repo":"larksuite/cli","slug":"invalid-file-path-q-w","errorCode":null,"errorMessage":"invalid file path %q: %w","messagePattern":"invalid file path %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmdutil/resolve.go","lineNumber":103,"sourceCode":"func ReadInputFile(fileIO fileio.FileIO, path string) ([]byte, error) {\n\tif fileIO == nil {\n\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":85,"sourceCodeEnd":107,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/cmdutil/resolve.go#L85-L107","documentation":"wrapInputFileError maps a fileio.ErrPathValidation failure from FileIO.Open into \"invalid file path %q: %w\", preserving the cause. It indicates the path failed validation (e.g. outside allowed roots, illegal characters, traversal) before any file was opened.","triggerScenarios":"Using --body @path where path is rejected by fileio path validation: absolute paths outside workspace roots, ../ traversal escaping the trust root, or other invalid path shapes.","commonSituations":"Referencing files outside the workspace/sidecar root; symlink or .. traversal attempts; Windows vs POSIX path confusion; migrating scripts that used absolute host paths into the scoped FileIO model.","solutions":["Use a path inside the validated workspace root (relative to the FileIO scope)","Resolve via runtime.ValidatePath()/runtime.ResolveSavePath() before referencing the file","Copy the file into the workspace tree first, then reference it","Pipe content via stdin (\"-\") when the file lives outside the trust root"],"exampleFix":"// before\nlark-cli cmd --body @/etc/payload.json\n// after\ncp /etc/payload.json ./payload.json\nlark-cli cmd --body @payload.json","handlingStrategy":"validation","validationCode":"// pre-validate with the runtime before using @path:\nif err := rt.ValidatePath(path); err != nil { /* use stdin or a workspace-relative path */ }","typeGuard":null,"tryCatchPattern":"var pv *fileio.PathError\nif err != nil && errors.As(err, &pv) {\n    fmt.Fprintf(os.Stderr, \"path %q rejected: %v; use a workspace-relative path\\n\", path, err)\n}","preventionTips":["Resolve paths via runtime.ValidatePath()/ResolveSavePath() before referencing","Keep referenced files inside the workspace/trust root","Avoid absolute paths and ../ traversal in scripts","Copy out-of-tree files into the workspace first"],"tags":["path-validation","fileio","file-input"],"backgroundTag":"invalid-file-path","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"}