{"record":{"id":"e2ad115c71214f27","repo":"wavetermdev/waveterm","slug":"getting-absolute-path-of-parent-dir-w","errorCode":null,"errorMessage":"getting absolute path of parent dir: %w","messagePattern":"getting absolute path of parent dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-view.go","lineNumber":82,"sourceCode":"\t\twshCmd = &wshrpc.CommandCreateBlockData{\n\t\t\tTabId: tabId,\n\t\t\tBlockDef: &waveobj.BlockDef{\n\t\t\t\tMeta: map[string]any{\n\t\t\t\t\twaveobj.MetaKey_View: \"web\",\n\t\t\t\t\twaveobj.MetaKey_Url:  fileArg,\n\t\t\t\t},\n\t\t\t},\n\t\t\tMagnified: viewMagnified,\n\t\t\tFocused:   true,\n\t\t}\n\t} else {\n\t\tabsFile, err := filepath.Abs(fileArg)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting absolute path: %w\", err)\n\t\t}\n\t\tabsParent, err := filepath.Abs(filepath.Dir(fileArg))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting absolute path of parent dir: %w\", err)\n\t\t}\n\t\t_, err = os.Stat(absParent)\n\t\tif err == fs.ErrNotExist {\n\t\t\treturn fmt.Errorf(\"parent directory does not exist: %q\", absParent)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting file info: %w\", err)\n\t\t}\n\t\twshCmd = &wshrpc.CommandCreateBlockData{\n\t\t\tTabId: tabId,\n\t\t\tBlockDef: &waveobj.BlockDef{\n\t\t\t\tMeta: map[string]interface{}{\n\t\t\t\t\twaveobj.MetaKey_View: \"preview\",\n\t\t\t\t\twaveobj.MetaKey_File: absFile,\n\t\t\t\t},\n\t\t\t},\n\t\t\tMagnified: viewMagnified,\n\t\t\tFocused:   true,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-view.go#L64-L100","documentation":"viewRun needs the parent directory of the target file (for MetaKey_FileDir metadata), so it computes filepath.Abs(filepath.Dir(fileArg)). If that conversion fails the command aborts with this wrapped error, distinct from the abs-path failure for the file itself.","triggerScenarios":"Same class of failure as the file abs-path error but during Dir() extraction: cwd cannot be determined (deleted cwd) or a malformed path argument makes filepath.Abs of the parent fail.","commonSituations":"Deleted or invalid current working directory; corrupt/unusual path inputs (embedded control characters, invalid Windows paths).","solutions":["Run from a valid working directory (`cd ~`)","Normalize the input path before passing it","Pass an already-absolute, well-formed path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"PARENT=$(dirname \"$TARGET\")\n[ -d \"$PARENT\" ] || { echo \"parent dir missing: $PARENT\" >&2; exit 1; }\nwsh view \"$TARGET\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize paths (realpath) before invoking","Run from a valid working directory"],"tags":["cli","filesystem","path-resolution"],"backgroundTag":"path-resolution-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}