{"record":{"id":"77d80c40069dbf37","repo":"wavetermdev/waveterm","slug":"seeking-file-w","errorCode":null,"errorMessage":"seeking file: %w","messagePattern":"seeking file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-wavepath.go","lineNumber":108,"sourceCode":"\t}\n\tdefer file.Close()\n\n\t// Get file size\n\tstat, err := file.Stat()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting file stats: %w\", err)\n\t}\n\n\t// Read last 16KB or whole file if smaller\n\treadSize := int64(16 * 1024)\n\tvar offset int64\n\tif stat.Size() > readSize {\n\t\toffset = stat.Size() - readSize\n\t}\n\n\t_, err = file.Seek(offset, 0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"seeking file: %w\", err)\n\t}\n\n\tbuf := make([]byte, readSize)\n\tn, err := file.Read(buf)\n\tif err != nil && err != io.EOF {\n\t\treturn fmt.Errorf(\"reading file: %w\", err)\n\t}\n\tbuf = buf[:n]\n\n\t// Skip partial line at start if we're not at beginning of file\n\tif offset > 0 {\n\t\tidx := bytes.IndexByte(buf, '\\n')\n\t\tif idx >= 0 {\n\t\t\tbuf = buf[idx+1:]\n\t\t}\n\t}\n\n\t// Split into lines","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-wavepath.go#L90-L126","documentation":"tailLogFile failed to Seek to the computed offset (file size minus 16KB, or 0). Seeking is required to read only the tail of a large log; failure indicates the file is not seekable or an I/O error occurred.","triggerScenarios":"`wsh wavepath log --tail` when the log path is a special/non-seekable file (pipe, device node) or an I/O error hits during seek on a network filesystem.","commonSituations":"Custom WAVE_LOG path pointing to a named pipe, or logs on flaky network mounts.","solutions":["Point logging at a regular file (check WAVETERM/wave log dir config).","Re-run on a healthy filesystem; retry transient I/O errors.","Read the whole file manually if small: `cat \"$(wsh wavepath log)\"`.","Drop --tail and just print the path."],"exampleFix":"// before\n_, err = file.Seek(offset, 0)\n// after\nif _, err = file.Seek(offset, io.SeekStart); err != nil { return fmt.Errorf(\"seeking file (seekable?): %w\", err) }","handlingStrategy":"fallback","validationCode":"fi, _ := os.Stat(path); seekable := fi.Mode().IsRegular()","typeGuard":"func isSeekable(fi os.FileInfo) bool { return fi.Mode().IsRegular() }","tryCatchPattern":"if _, err := file.Seek(offset, 0); err != nil {\n    // fallback: read whole file from start\n    file.Seek(0, io.SeekStart)\n    io.Copy(os.Stdout, file)\n    return nil\n}","preventionTips":["Ensure the log path is a regular file, not a pipe/device.","Avoid pointing wave logs at non-seekable targets.","Fall back to full-file reads when seek fails."],"tags":["filesystem","file-io","seek"],"backgroundTag":"file-seek-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}