{"record":{"id":"1a17ff7274427108","repo":"alibaba/open-code-review","slug":"w-run-ocr-session-list-to-see-available-sessio-1a17ff","errorCode":null,"errorMessage":"%w (run 'ocr session list' to see available sessions)","messagePattern":"%w \\(run 'ocr session list' to see available sessions\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/scan_cmd.go","lineNumber":258,"sourceCode":"\t\tif id := ag.SessionID(); id != \"\" {\n\t\t\tfmt.Fprintf(os.Stderr, \"[ocr] Session: %s (retry with: --resume %s)\\n\", id, id)\n\t\t}\n\t\treturn fmt.Errorf(\"scan failed: %w\", err)\n\t}\n\n\treturn emitRunResult(ctx, ag, comments, startTime, opts.outputFormat, opts.audience, q, llmIdentity, out, nil)\n}\n\nfunc loadScanResumeState(repoDir string, opts scanOptions, scanPaths []string) (*session.ResumeState, error) {\n\tif opts.resume == \"\" {\n\t\treturn nil, nil\n\t}\n\tstate, err := session.LoadResumeState(repoDir, opts.resume)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load resume session: %w (run 'ocr session list' to see available sessions)\", err)\n\t}\n\tif err := state.ValidateScanOptions(scanPaths); err != nil {\n\t\treturn nil, fmt.Errorf(\"%w (run 'ocr session list' to see available sessions)\", err)\n\t}\n\tif state.CompletedCount() == 0 {\n\t\treturn nil, fmt.Errorf(\"resume session %q has no completed scan items (run 'ocr session list' to see available sessions)\", opts.resume)\n\t}\n\treturn state, nil\n}\n\nfunc runScanPreview(cc *commonContext, scanTpl *template.ScanTemplate, scanPaths []string, outputFormat string, out io.Writer) error {\n\tpreview, err := scan.Preview(context.Background(), scan.Args{\n\t\tRepoDir:          cc.RepoDir,\n\t\tPaths:            scanPaths,\n\t\tFileFilter:       cc.FileFilter,\n\t\tGitRunner:        cc.GitRunner,\n\t\tMaxFileSizeBytes: scanTpl.MaxFileSizeBytes,\n\t\t// Template's prompt fields are unused by Preview; pass the same\n\t\t// value so MaxFileSizeBytes is consistent.\n\t\tTemplate: *scanTpl,\n\t})","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/scan_cmd.go#L240-L276","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nocr scan --resume abc123 --path internal/agent\n// after (match the original scope)\nocr scan --resume abc123","handlingStrategy":"validation","validationCode":"state, err := session.LoadResumeState(repoDir, opts.resume)\nif err == nil {\n    if err := state.ValidateScanOptions(scanPaths); err != nil {\n        return fmt.Errorf(\"path scope mismatch: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := state.ValidateScanOptions(scanPaths); err != nil {\n    return fmt.Errorf(\"%w; rerun with the original scan arguments or start a new scan\", err)\n}","preventionTips":["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."],"tags":["go","cli","session","resume","validation"],"backgroundTag":"resume-scope-mismatch","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}