{"record":{"id":"ea3b2b75f4dd006b","repo":"alibaba/open-code-review","slug":"list-sessions-w","errorCode":null,"errorMessage":"list sessions: %w","messagePattern":"list sessions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/session_cmd.go","lineNumber":156,"sourceCode":"\tsessionCommentsCmd.RegisterFlagCompletionFunc(\"category\", completeEnum(\"bug\", \"security\", \"performance\", \"maintainability\", \"test\", \"style\", \"documentation\", \"other\"))\n\n\tsessionCompareCmd.Flags().StringVar(&sessionCompareRepoDir, \"repo\", \"\", \"root directory of the git repository (default: current dir)\")\n\tsessionCompareCmd.Flags().BoolVar(&sessionCompareJSON, \"json\", false, \"emit the comparison as JSON\")\n\n\tsessionCmd.AddCommand(sessionListCmd)\n\tsessionCmd.AddCommand(sessionShowCmd)\n\tsessionCmd.AddCommand(sessionCommentsCmd)\n\tsessionCmd.AddCommand(sessionCompareCmd)\n}\n\nfunc runSessionList() error {\n\tresolvedRepo, err := resolveWorkingDirForSession(sessionListRepoDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsummaries, err := session.ListSessions(resolvedRepo)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"list sessions: %w\", err)\n\t}\n\tif sessionListLimit > 0 && len(summaries) > sessionListLimit {\n\t\tsummaries = summaries[:sessionListLimit]\n\t}\n\n\tif sessionListJSON {\n\t\tenc := json.NewEncoder(os.Stdout)\n\t\tenc.SetIndent(\"\", \"  \")\n\t\treturn enc.Encode(summaries)\n\t}\n\n\tif len(summaries) == 0 {\n\t\tfmt.Printf(\"No sessions found for %s\\n\", resolvedRepo)\n\t\treturn nil\n\t}\n\tprintSessionTable(os.Stdout, summaries)\n\treturn nil\n}","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/session_cmd.go#L138-L174","documentation":"`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\".","triggerScenarios":"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.","commonSituations":"$HOME not writable/resolvable (containers, sudo); sessions dir manually deleted mid-read or partially copied; corrupted JSONL files from a killed ocr process.","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."],"exampleFix":"// before (unreadable store)\nls: ~/.opencodereview/sessions: Permission denied\n// after\nchmod u+rx ~/.opencodereview ~/.opencodereview/sessions && ocr session list","handlingStrategy":"try-catch","validationCode":"if home, err := os.UserHomeDir(); err != nil || !writable(filepath.Join(home, \".opencodereview\", \"sessions\")) {\n    return fmt.Errorf(\"session store unavailable; fix $HOME or permissions\")\n}","typeGuard":null,"tryCatchPattern":"summaries, err := session.ListSessions(resolvedRepo)\nif err != nil {\n    // Surface the inner cause (permissions vs corrupted file) to the user\n    return fmt.Errorf(\"list sessions: %v (check ~/.opencodereview/sessions)\", err)\n}","preventionTips":["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."],"tags":["go","cli","session","filesystem"],"backgroundTag":"session-store-unreadable","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}