{"record":{"id":"6dca992167bd6a1a","repo":"wavetermdev/waveterm","slug":"tailing-log-file-w","errorCode":null,"errorMessage":"tailing log file: %w","messagePattern":"tailing log file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-wavepath.go","lineNumber":77,"sourceCode":"\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\n\tpath, err := wshclient.PathCommand(RpcClient, wshrpc.PathCommandData{\n\t\tPathType:     pathType,\n\t\tOpen:         open,\n\t\tOpenExternal: openExternal,\n\t\tTabId:        tabId,\n\t}, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting path: %w\", err)\n\t}\n\n\tif tail && pathType == \"log\" {\n\t\terr = tailLogFile(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"tailing log file: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tWriteStdout(\"%s\\n\", path)\n\treturn nil\n}\n\nfunc tailLogFile(path string) error {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"opening log file: %w\", err)\n\t}\n\tdefer file.Close()\n\n\t// Get file size\n\tstat, err := file.Stat()\n\tif err != nil {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-wavepath.go#L59-L95","documentation":"This wraps any error from tailLogFile, the local routine that reads and streams the last 16KB (and then follows) the log file. The RPC succeeded and returned a path, but local file access or stat/seek/read failed; the cause is preserved.","triggerScenarios":"`wsh wavepath log --tail` where the returned log path cannot be opened, stat'ed, seeked, or read (file deleted, rotated away, permission denied, or path points to a non-regular file).","commonSituations":"Log rotation removing the file between RPC and tail, running wsh as a user without read access to Wave's log dir, or log path on an unmounted volume.","solutions":["Check the file exists and is readable: `ls -l <path>` and `tail -c 1k <path>`.","Fix permissions on the Wave log directory or run as the user who owns the terminal.","Re-run the command to pick up a fresh path after log rotation.","If tailing isn't essential, use `wsh wavepath log` without --tail."],"exampleFix":"// before\nerr = tailLogFile(path) // fails on rotated file\n// after\nif _, err := os.Stat(path); os.IsNotExist(err) { path, err = refreshLogPath() }","handlingStrategy":"retry","validationCode":"logpath=$(wsh wavepath log) && [ -r \"$logpath\" ] && [ -f \"$logpath\" ] || exit 1","typeGuard":null,"tryCatchPattern":"err := tailLogFile(path)\nif err != nil {\n    time.Sleep(500 * time.Millisecond)\n    if retryErr := tailLogFile(path); retryErr != nil { return fmt.Errorf(\"tailing log file: %w\", retryErr) }\n}","preventionTips":["Re-fetch the path after log rotation instead of reusing old paths.","Check readability/permissions of the Wave log directory.","Prefer plain `wsh wavepath log` when only the path is needed."],"tags":["filesystem","file-io","wsh"],"backgroundTag":"file-open-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}