{"record":{"id":"899175ccd9703986","repo":"alibaba/open-code-review","slug":"read-session-q-w","errorCode":null,"errorMessage":"read session %q: %w","messagePattern":"read session %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/session/list.go","lineNumber":216,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"open session %q: %w\", path, err)\n\t}\n\tdefer f.Close()\n\n\treader := bufio.NewReader(f)\n\tfor {\n\t\tline, readErr := reader.ReadBytes('\\n')\n\t\tif len(line) > 0 {\n\t\t\tvar rec summaryRecord\n\t\t\tif err := json.Unmarshal(line, &rec); err == nil {\n\t\t\t\tapply(rec)\n\t\t\t}\n\t\t}\n\t\tif readErr == io.EOF {\n\t\t\treturn nil\n\t\t}\n\t\tif readErr != nil {\n\t\t\treturn fmt.Errorf(\"read session %q: %w\", path, readErr)\n\t\t}\n\t}\n}\n\nfunc applyRecordToSummary(s *Summary, rec summaryRecord) {\n\tts := parseRecordTime(rec.Timestamp)\n\tswitch rec.Type {\n\tcase \"session_start\":\n\t\tif rec.SessionID != \"\" {\n\t\t\ts.SessionID = rec.SessionID\n\t\t}\n\t\tif rec.Cwd != \"\" {\n\t\t\ts.RepoDir = rec.Cwd\n\t\t}\n\t\ts.GitBranch = rec.GitBranch\n\t\ts.Model = rec.Model\n\t\ts.ReviewMode = rec.ReviewMode\n\t\ts.DiffFrom = rec.DiffFrom","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/session/list.go#L198-L234","documentation":"While streaming a session .jsonl file, walkSessionFile reads it line-by-line with bufio.Reader.ReadBytes. If a read fails for a reason other than clean io.EOF, the error is wrapped as 'read session %q: ...'. This indicates the file became unreadable mid-read or I/O failed — not malformed content per se, but an OS-level read error.","triggerScenarios":"LoadComments/LoadDetail/loadSummaryFromFile → walkSessionFile when ReadBytes returns a non-EOF error: file truncated/modified concurrently, I/O error, or (depending on handling) an oversized line hitting the buffer limit.","commonSituations":"Session file being written by a concurrent ocr process; disk errors or failing NFS mount; file replaced (renamed) between open and read; corrupt filesystem.","solutions":["Wait for any concurrent ocr run to finish, then retry reading the session.","Verify disk health / remount the filesystem if I/O errors persist.","Delete the corrupt session file and rely on a fresh session (or restore from backup).","Check the wrapped cause (%w) for the exact errno (EIO, ESTALE, etc.)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure no concurrent writer is holding the session open\nif locked := isProcessWriting(sessionPath); locked {\n    return fmt.Errorf(\"session file is being written; retry after the run finishes\")\n}","typeGuard":null,"tryCatchPattern":"comments, err := session.LoadComments(repoDir, sessionID)\nif err != nil {\n    if strings.Contains(err.Error(), \"read session\") {\n        time.Sleep(2 * time.Second) // transient I/O; retry once\n        return session.LoadComments(repoDir, sessionID)\n    }\n    return err\n}","preventionTips":["Don't read session files while a concurrent ocr run is writing them.","Avoid storing sessions on flaky network filesystems.","Monitor disk health; EIO during reads indicates failing storage.","If a file is corrupt/truncated, delete it and generate a fresh session."],"tags":["session","io","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}