alibaba/open-code-review · error
%w (run 'ocr session list' to see available sessions)
Error message
%w (run 'ocr session list' to see available sessions)
What it means
After successfully loading the resume state, `ocr scan --resume` validates that the current --path arguments match the session's recorded scan-path scope (ResumeState.ValidateScanOptions). A mismatch — e.g. resuming a whole-repo scan while now passing --path internal/foo — is rejected and wrapped as "%w (run 'ocr session list' ...)" to steer users toward compatible sessions.
Source
Thrown at cmd/opencodereview/scan_cmd.go:258
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 same
// value so MaxFileSizeBytes is consistent.
Template: *scanTpl,
})View on GitHub (pinned to 5cf97d0d15)
Solutions
- Re-run the resume with the same --path/--exclude arguments used in the original scan command.
- If you want a different scope, start a new scan instead of resuming (checkpoints only apply to the recorded scope).
- Compare with `ocr session show <id>` to see the session's recorded scan paths.
- Run `ocr session list` if unsure which session matches your intended scope.
Example fix
// before ocr scan --resume abc123 --path internal/agent // after (match the original scope) ocr scan --resume abc123
Defensive patterns
Strategy: validation
Validate before calling
state, err := session.LoadResumeState(repoDir, opts.resume)
if err == nil {
if err := state.ValidateScanOptions(scanPaths); err != nil {
return fmt.Errorf("path scope mismatch: %w", err)
}
} Try / catch
if err := state.ValidateScanOptions(scanPaths); err != nil {
return fmt.Errorf("%w; rerun with the original scan arguments or start a new scan", err)
} Prevention
- Reuse the exact original command line (same --path/--exclude) when resuming.
- Consult `ocr session show <id>` for the recorded scan paths before resuming.
- Start a new scan rather than changing scope mid-resume.
When it happens
Trigger: Running `ocr scan --resume <id> --path A` (or --exclude) where the path scope differs from the ScanPaths recorded in the session's session_start record.
Common situations: Narrowing a resumed scan to a subdirectory after a failed full scan; adding/removing --exclude flags between the original run and the resume; running the resume from a different repo whose recorded scope differs.
Related errors
- load resume session: %w (run 'ocr session list' to see avail
- resume session %q has no completed scan items (run 'ocr sess
- sessions belong to different repositories: %s was recorded i
- resume requires --from/--to or --commit; workspace resume is
- background file %q is a directory, not a file
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/1a17ff7274427108.
Report an issue: GitHub.