alibaba/open-code-review · error
load resume session: %w (run 'ocr session list' to see avail
Error message
load resume session: %w (run 'ocr session list' to see available sessions)
What it means
`ocr scan --resume <id>` replays the stored session JSONL (~/.opencodereview/sessions/<encoded-repo>/<id>.jsonl) via session.LoadResumeState to build a checkpoint index. If the file cannot be opened (nonexistent session, wrong repo dir) or a record cannot be parsed (LoadResumeState is strict: unparseable lines fail the load, unlike the review variant), the CLI wraps it as "load resume session: %w (run 'ocr session list' to see available sessions)".
Source
Thrown at cmd/opencodereview/scan_cmd.go:255
if err != nil {
span.SetStatus(codes.Error, err.Error())
span.RecordError(err)
if id := ag.SessionID(); id != "" {
fmt.Fprintf(os.Stderr, "[ocr] Session: %s (retry with: --resume %s)\n", id, id)
}
return fmt.Errorf("scan failed: %w", err)
}
return emitRunResult(ctx, ag, comments, startTime, opts.outputFormat, opts.audience, q, llmIdentity, out, nil)
}
func loadScanResumeState(repoDir string, opts scanOptions, scanPaths []string) (*session.ResumeState, error) {
if opts.resume == "" {
return nil, nil
}
state, err := session.LoadResumeState(repoDir, opts.resume)
if err != nil {
return nil, fmt.Errorf("load resume session: %w (run 'ocr session list' to see available sessions)", err)
}
if err := state.ValidateScanOptions(scanPaths); err != nil {
return nil, fmt.Errorf("%w (run 'ocr session list' to see available sessions)", err)
}
if state.CompletedCount() == 0 {
return nil, fmt.Errorf("resume session %q has no completed scan items (run 'ocr session list' to see available sessions)", opts.resume)
}
return state, nil
}
func runScanPreview(cc *commonContext, scanTpl *template.ScanTemplate, scanPaths []string, outputFormat string, out io.Writer) error {
preview, err := scan.Preview(context.Background(), scan.Args{
RepoDir: cc.RepoDir,
Paths: scanPaths,
FileFilter: cc.FileFilter,
GitRunner: cc.GitRunner,
MaxFileSizeBytes: scanTpl.MaxFileSizeBytes,
// Template's prompt fields are unused by Preview; pass the sameView on GitHub (pinned to 5cf97d0d15)
Solutions
- Run `ocr session list` in the same repo and copy the exact session id.
- Confirm you are in the same repository directory the original scan ran from (sessions are keyed by repo path).
- If the JSONL is corrupted, restore from backup or start a fresh scan instead of resuming.
- Check ~/.opencodereview/sessions/<encoded-repo-path>/<id>.jsonl exists and every line is valid JSON (jq -c . file).
Example fix
// before ocr scan --resume 3f9a // after ocr session list # find the full id ocr scan --resume 3f9a1b2c-4d5e-6f70-...
Defensive patterns
Strategy: validation
Validate before calling
id := opts.resume
path := filepath.Join(home, ".opencodereview", "sessions", encodeRepoPath(repoDir), id+".jsonl")
if fi, err := os.Stat(path); err != nil || fi.Size() == 0 {
return fmt.Errorf("resume session %s not found in this repo; run 'ocr session list'", id)
} Type guard
func resumeFileExists(repoDir, sessionID string) bool {
p, err := session.SessionFilePath(repoDir, sessionID)
if err != nil {
return false
}
fi, err := os.Stat(p)
return err == nil && !fi.IsDir() && fi.Size() > 0
} Try / catch
state, err := session.LoadResumeState(repoDir, opts.resume)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
ids := mustListSessions(repoDir)
return fmt.Errorf("unknown session %q; did you mean one of %v?", opts.resume, ids)
}
return err // corrupted line: surface, don't mask
} Prevention
- Copy session ids from `ocr session list`, never retype them.
- Resume from the same repository directory (store is keyed by repo path).
- Don't hand-edit session JSONL files; a single invalid line fails the strict scan resume load.
- Back up ~/.opencodereview/sessions before cleaning home directories.
When it happens
Trigger: Running `ocr scan --resume <id>` when the JSONL does not exist for this repo (typo'd id, different repository, cleaned ~/.opencodereview), or when the file contains a line that fails json.Unmarshal / is unknown to the parser (hand-edited or corrupted checkpoint).
Common situations: Resuming from another machine or after HOME changed; resuming a session created in a different repo directory; truncated/corrupted JSONL from a killed process mid-write; manually editing the session file.
Related errors
- %w (run 'ocr session list' to see available sessions)
- resume session %q has no completed scan items (run 'ocr sess
- list sessions: %w
- load session %q: %w
- sessions belong to different repositories: %s was recorded i
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/626e3d5232ecddb6.
Report an issue: GitHub.