{"record":{"id":"9ecf34160506a87d","repo":"alibaba/open-code-review","slug":"open-session-q-w","errorCode":null,"errorMessage":"open session %q: %w","messagePattern":"open session %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/session/list.go","lineNumber":199,"sourceCode":"\t\tFilePath:  path,\n\t\tRepoDir:   repoDir,\n\t\tAborted:   true,\n\t}\n\tif err := walkSessionFile(path, func(rec summaryRecord) {\n\t\tapplyRecordToSummary(summary, rec)\n\t}); err != nil {\n\t\treturn nil, err\n\t}\n\tif summary.SessionID == \"\" {\n\t\tsummary.SessionID = sessionID\n\t}\n\treturn summary, nil\n}\n\nfunc walkSessionFile(path string, apply func(summaryRecord)) error {\n\tf, err := os.Open(path)\n\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}","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/session/list.go#L181-L217","documentation":"walkSessionFile opens a persisted .jsonl session file to apply records. If os.Open fails, the error is wrapped as 'open session %q: ...'. This is reached by LoadComments, LoadDetail, and loadSummaryFromFile when a specific session file cannot be opened.","triggerScenarios":"Loading a session by ID or path when the .jsonl file is missing (deleted or wrong session ID), unreadable (permissions), or the resolved path points elsewhere (repo re-encoded path mismatch).","commonSituations":"Session file deleted manually or by cleanup scripts; running as a different user than the one that created the session; typo'd or stale session ID; path traversal of an encoded repo path after the repo moved.","solutions":["Verify the session ID exists: `ocr session list` and use an ID from its output.","Check file permissions on ~/.opencodereview/sessions/<repo>/<id>.jsonl and fix with chown/chmod.","Re-create the session file by re-running the review/scan command if it was deleted.","If the repo path changed, note the encoded directory name changes; run sessions from the new path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"sessions, err := session.ListSessions(repoDir)\nif err != nil {\n    return err\n}\nfound := false\nfor _, s := range sessions {\n    if s.ID == wantedID {\n        found = true\n    }\n}\nif !found {\n    return fmt.Errorf(\"session %s not found; pick an ID from session list\", wantedID)\n}","typeGuard":null,"tryCatchPattern":"comments, err := session.LoadComments(repoDir, sessionID)\nif err != nil {\n    if strings.Contains(err.Error(), \"open session\") {\n        return fmt.Errorf(\"session %s missing or unreadable; run `ocr session list`: %w\", sessionID, err)\n    }\n    return err\n}","preventionTips":["Always resolve session IDs via `session list` before loading.","Avoid deleting or rotating session files while readers may be active.","Keep file permissions consistent across users running the tool.","If the repo path moved, expect a new encoded directory; load from the new path."],"tags":["session","filesystem","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}