wavetermdev/waveterm · error
getting absolute path of parent dir: %w
Error message
getting absolute path of parent dir: %w
What it means
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.
Source
Thrown at cmd/wsh/cmd/wshcmd-view.go:82
wshCmd = &wshrpc.CommandCreateBlockData{
TabId: tabId,
BlockDef: &waveobj.BlockDef{
Meta: map[string]any{
waveobj.MetaKey_View: "web",
waveobj.MetaKey_Url: fileArg,
},
},
Magnified: viewMagnified,
Focused: true,
}
} else {
absFile, err := filepath.Abs(fileArg)
if err != nil {
return fmt.Errorf("getting absolute path: %w", err)
}
absParent, err := filepath.Abs(filepath.Dir(fileArg))
if err != nil {
return fmt.Errorf("getting absolute path of parent dir: %w", err)
}
_, err = os.Stat(absParent)
if err == fs.ErrNotExist {
return fmt.Errorf("parent directory does not exist: %q", absParent)
}
if err != nil {
return fmt.Errorf("getting file info: %w", err)
}
wshCmd = &wshrpc.CommandCreateBlockData{
TabId: tabId,
BlockDef: &waveobj.BlockDef{
Meta: map[string]interface{}{
waveobj.MetaKey_View: "preview",
waveobj.MetaKey_File: absFile,
},
},
Magnified: viewMagnified,
Focused: true,View on GitHub (pinned to a4447c1563)
Solutions
- Run from a valid working directory (`cd ~`)
- Normalize the input path before passing it
- Pass an already-absolute, well-formed path
Defensive patterns
Strategy: validation
Validate before calling
PARENT=$(dirname "$TARGET")
[ -d "$PARENT" ] || { echo "parent dir missing: $PARENT" >&2; exit 1; }
wsh view "$TARGET" Prevention
- Normalize paths (realpath) before invoking
- Run from a valid working directory
When it happens
Trigger: 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.
Common situations: Deleted or invalid current working directory; corrupt/unusual path inputs (embedded control characters, invalid Windows paths).
Related errors
- getting absolute path: %w
- resolving image path: %v
- getting absolute path: %w
- file does not exist: %q
- getting file info: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/e2ad115c71214f27.
Report an issue: GitHub.