{"record":{"id":"3634b903d6f8758b","repo":"wavetermdev/waveterm","slug":"getting-file-info-w","errorCode":null,"errorMessage":"getting file info: %w","messagePattern":"getting file info: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-editor.go","lineNumber":55,"sourceCode":"\tif len(args) == 0 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"no arguments.  wsh editor requires a file or URL as an argument argument\")\n\t}\n\tif len(args) > 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments.  wsh editor requires exactly one argument\")\n\t}\n\tfileArg := args[0]\n\tabsFile, err := filepath.Abs(fileArg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting absolute path: %w\", err)\n\t}\n\t_, err = os.Stat(absFile)\n\tif err == fs.ErrNotExist {\n\t\treturn fmt.Errorf(\"file does not exist: %q\", absFile)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting file info: %w\", err)\n\t}\n\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\n\twshCmd := wshrpc.CommandCreateBlockData{\n\t\tTabId: tabId,\n\t\tBlockDef: &waveobj.BlockDef{\n\t\t\tMeta: map[string]any{\n\t\t\t\twaveobj.MetaKey_View: \"preview\",\n\t\t\t\twaveobj.MetaKey_File: absFile,\n\t\t\t\twaveobj.MetaKey_Edit: true,\n\t\t\t},\n\t\t},\n\t\tMagnified: editMagnified,\n\t\tFocused:   true,","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-editor.go#L37-L73","documentation":"If os.Stat fails with an error other than fs.ErrNotExist (permission denied, I/O error, too many symlinks, etc.), editorRun wraps it as \"getting file info\". This distinguishes general stat failures from the plain not-exist case.","triggerScenarios":"os.Stat returning e.g. EACCES on a parent directory, ELOOP from symlink cycles, or device/IO errors while stating the path.","commonSituations":"File inside a directory the user cannot traverse; broken symlink loops; files on unmounted or failing volumes.","solutions":["Check permissions on the file and each parent directory (`ls -ld`)","Inspect the wrapped inner error for the exact errno","Resolve symlink loops with `readlink -f`","Ensure the volume/mount holding the file is available"],"exampleFix":"// before\nwsh editor /root/secret.txt  # permission denied\n// after\nchmod o+rx /root && wsh editor /root/secret.txt  # or use an accessible path","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(path); err != nil && !errors.Is(err, fs.ErrNotExist) {\n    return fmt.Errorf(\"cannot access %q: %v\", path, err)\n}","typeGuard":null,"tryCatchPattern":"if err := wsh.Editor(path); err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        log.Printf(\"stat failed on %s: %v\", perr.Path, perr.Err)\n        // fix permissions/symlinks based on perr.Err\n    }\n}","preventionTips":["Check directory traversal permissions (o+x) on parent dirs","Avoid symlink loops; use readlink -f to normalize","Keep target volumes mounted before running editor commands"],"tags":["filesystem","permissions","cli"],"backgroundTag":"file-stat-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}