alibaba/open-code-review · error
list sessions: %w
Error message
list sessions: %w
What it means
`ocr session list` enumerates persisted session summaries for the resolved repository directory via session.ListSessions. Any error reading/decoding the session store (unreadable ~/.opencodereview/sessions/<repo>/ directory, corrupted JSONL preventing summary extraction) is wrapped as "list sessions: %w".
Source
Thrown at cmd/opencodereview/session_cmd.go:156
sessionCommentsCmd.RegisterFlagCompletionFunc("category", completeEnum("bug", "security", "performance", "maintainability", "test", "style", "documentation", "other"))
sessionCompareCmd.Flags().StringVar(&sessionCompareRepoDir, "repo", "", "root directory of the git repository (default: current dir)")
sessionCompareCmd.Flags().BoolVar(&sessionCompareJSON, "json", false, "emit the comparison as JSON")
sessionCmd.AddCommand(sessionListCmd)
sessionCmd.AddCommand(sessionShowCmd)
sessionCmd.AddCommand(sessionCommentsCmd)
sessionCmd.AddCommand(sessionCompareCmd)
}
func runSessionList() error {
resolvedRepo, err := resolveWorkingDirForSession(sessionListRepoDir)
if err != nil {
return err
}
summaries, err := session.ListSessions(resolvedRepo)
if err != nil {
return fmt.Errorf("list sessions: %w", err)
}
if sessionListLimit > 0 && len(summaries) > sessionListLimit {
summaries = summaries[:sessionListLimit]
}
if sessionListJSON {
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
return enc.Encode(summaries)
}
if len(summaries) == 0 {
fmt.Printf("No sessions found for %s\n", resolvedRepo)
return nil
}
printSessionTable(os.Stdout, summaries)
return nil
}View on GitHub (pinned to 5cf97d0d15)
Solutions
- Inspect the wrapped cause: fix filesystem permissions on ~/.opencodereview/sessions or set HOME correctly.
- Delete or repair the specific corrupted <id>.jsonl named in the inner error (move it aside and retry).
- Recreate the sessions directory empty if contents are unrecoverable (old sessions are then lost).
- Run from the same repository so the encoded repo path matches; a different cwd changes which store is read.
Example fix
// before (unreadable store) ls: ~/.opencodereview/sessions: Permission denied // after chmod u+rx ~/.opencodereview ~/.opencodereview/sessions && ocr session list
Defensive patterns
Strategy: try-catch
Validate before calling
if home, err := os.UserHomeDir(); err != nil || !writable(filepath.Join(home, ".opencodereview", "sessions")) {
return fmt.Errorf("session store unavailable; fix $HOME or permissions")
} Try / catch
summaries, err := session.ListSessions(resolvedRepo)
if err != nil {
// Surface the inner cause (permissions vs corrupted file) to the user
return fmt.Errorf("list sessions: %v (check ~/.opencodereview/sessions)", err)
} Prevention
- Keep ~/.opencodereview/sessions readable/writable by the running user.
- Don't run ocr under sudo with a different HOME than the one holding sessions.
- Move corrupted JSONL files aside rather than deleting the whole store.
- Set LC_ALL/HOME explicitly in CI containers.
When it happens
Trigger: Running `ocr session list` when the sessions directory cannot be read (permissions, HOME unresolved) or one or more stored session JSONL files fail to parse while building summaries.
Common situations: $HOME not writable/resolvable (containers, sudo); sessions dir manually deleted mid-read or partially copied; corrupted JSONL files from a killed ocr process.
Related errors
- read background file %q: %w
- background file %q is a directory, not a file
- load resume session: %w (run 'ocr session list' to see avail
- %w (run 'ocr session list' to see available sessions)
- resume session %q has no completed scan items (run 'ocr sess
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/ea3b2b75f4dd006b.
Report an issue: GitHub.