{"record":{"id":"ad8519edbac8877d","repo":"alibaba/open-code-review","slug":"open-resume-session-q-w","errorCode":null,"errorMessage":"open resume session %q: %w","messagePattern":"open resume session %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/session/resume.go","lineNumber":118,"sourceCode":"\n// LoadReviewResumeState replays a review session, dropping records it cannot\n// parse. Review reuse is gated on the parent manifest rather than on these lines\n// (see ReusableItem), so an unreadable checkpoint just means its file is reviewed\n// again — which is what a corrupted checkpoint is supposed to do. Failing the\n// whole load instead would turn one bad line into the loss of every other file's\n// checkpoint.\nfunc LoadReviewResumeState(repoDir, sessionID string) (*ResumeState, error) {\n\treturn loadResumeState(repoDir, sessionID, true)\n}\n\nfunc loadResumeState(repoDir, sessionID string, skipUnparseable bool) (*ResumeState, error) {\n\tpath, err := SessionFilePath(repoDir, sessionID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"open resume session %q: %w\", sessionID, err)\n\t}\n\tdefer f.Close()\n\n\tstate := &ResumeState{\n\t\tSessionID: sessionID,\n\t\tRepoDir:   repoDir,\n\t\tItems:     make(map[string]ResumeItem),\n\t}\n\treader := bufio.NewReader(f)\n\tfor {\n\t\tline, readErr := reader.ReadBytes('\\n')\n\t\tif len(line) > 0 {\n\t\t\tif err := state.applyResumeLine(line); err != nil && !skipUnparseable {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\tif readErr == io.EOF {\n\t\t\tbreak","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/session/resume.go#L100-L136","documentation":"loadResumeState wraps the os.Open failure when replaying a persisted session JSONL from ~/.opencodereview/<repo>/<sessionID>.jsonl. The library throws it because without the session file there is no checkpoint index to rebuild, so resume cannot proceed. The wrapped os error (usually fs.ErrNotExist) names the real cause.","triggerScenarios":"Calling LoadResumeState or LoadReviewResumeState with a sessionID whose JSONL does not exist under ~/.opencodereview/, a misspelled/typo'd --session id, a file deleted by cleanup or another machine, or SessionFilePath failing to resolve the home dir is a separate error (this one is the os.Open failure).","commonSituations":"Users resume on a different machine or after wiping HOME; a stale session id from an old repo path encoding; the session file was pruned by a cleanup script; typo in the session id passed on the CLI.","solutions":["List actual sessions in ~/.opencodereview/<encoded-repo-path>/ and use an existing session id","Check errors.Is(err, fs.ErrNotExist) vs permission/disk errors and fix HOME or permissions accordingly","If the file is genuinely gone, start a fresh review instead of resuming"],"exampleFix":"// before\nstate, err := session.LoadResumeState(repoDir, sessionID)\n// after\nstate, err := session.LoadResumeState(repoDir, sessionID)\nif errors.Is(err, fs.ErrNotExist) {\n\tlog.Printf(\"no prior session %q; starting fresh\", sessionID)\n\treturn runFreshReview(opts)\n}","handlingStrategy":"fallback","validationCode":"path, _ := session.SessionFilePath(repoDir, sessionID)\nif _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {\n\t// no session to resume; go fresh\n}","typeGuard":"func sessionExists(repoDir, sessionID string) bool {\n\tpath, err := session.SessionFilePath(repoDir, sessionID)\n\tif err != nil { return false }\n\t_, statErr := os.Stat(path)\n\treturn statErr == nil\n}","tryCatchPattern":"state, err := session.LoadResumeState(repoDir, sessionID)\nif err != nil {\n\tif errors.Is(err, fs.ErrNotExist) { return runFresh(opts) }\n\treturn fmt.Errorf(\"resume: %w\", err)\n}","preventionTips":["Verify the session id against files in ~/.opencodereview/<encoded-repo>/ before resuming","Expect session files to be machine-local; never resume an id from another host","Log the resolved SessionFilePath so missing-file errors are diagnosable"],"tags":["go","file-io","resume","session"],"backgroundTag":"session-file-not-found","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}