{"record":{"id":"4cc10fd9337b302e","repo":"alibaba/open-code-review","slug":"resume-session-review-mode-q-does-not-match-curre","errorCode":null,"errorMessage":"resume session review mode %q does not match current mode %q","messagePattern":"resume session review mode %q does not match current mode %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/session/resume.go","lineNumber":285,"sourceCode":"\n// ValidateOptions verifies that this session can be resumed in the requested\n// review mode at all. It deliberately does not compare the ref text the user\n// typed: `abc1234` and `abc1234def` can name the same commit while a ref whose\n// name did not change can name a new one, so ref spellings are neither\n// sufficient nor necessary evidence about the input. ValidateResume compares the\n// resolved input identity instead.\nfunc (s *ResumeState) ValidateOptions(opts SessionOptions) error {\n\tif s == nil {\n\t\treturn nil\n\t}\n\tif opts.ReviewMode == \"\" || opts.ReviewMode == ReviewModeWorkspace {\n\t\treturn fmt.Errorf(\"resume requires --from/--to or --commit; workspace resume is not supported\")\n\t}\n\tif s.ReviewMode == \"\" {\n\t\treturn fmt.Errorf(\"resume session %q is missing review mode metadata\", s.SessionID)\n\t}\n\tif s.ReviewMode != opts.ReviewMode {\n\t\treturn fmt.Errorf(\"resume session review mode %q does not match current mode %q\", s.ReviewMode, opts.ReviewMode)\n\t}\n\tif opts.ReviewMode != ReviewModeRange && opts.ReviewMode != ReviewModeCommit {\n\t\treturn fmt.Errorf(\"resume mode %q is not supported\", opts.ReviewMode)\n\t}\n\treturn nil\n}\n\n// ValidateScanOptions verifies that the previous session was a full-file scan.\nfunc (s *ResumeState) ValidateScanOptions(scanPaths []string) error {\n\tif s == nil {\n\t\treturn nil\n\t}\n\tif s.ReviewMode == \"\" {\n\t\treturn fmt.Errorf(\"resume session %q is missing review mode metadata\", s.SessionID)\n\t}\n\tif s.ReviewMode != ReviewModeFullScan {\n\t\treturn fmt.Errorf(\"resume session review mode %q does not match current mode %q\", s.ReviewMode, ReviewModeFullScan)\n\t}","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/session/resume.go#L267-L303","documentation":"ResumeState.ValidateOptions rejects when the previous session's review mode differs from the currently requested one. Checkpoints (fingerprints, diff identity) are only meaningful within the same review mode, so cross-mode resume is refused.","triggerScenarios":"Prior session was --commit but the resume request is --from/--to (range), or vice versa; prior was full-scan and the user now asks for range resume (or any other mode combination mismatch).","commonSituations":"User switches review workflow between commits and PR ranges but reuses an old --resume id; CI passes a different mode flag than the original run; muscle-memory flag reuse from a previous invocation.","solutions":["Invoke resume with the same mode the original session used (check the session JSONL's reviewMode field)","Run a fresh review in the new mode instead of resuming","Start a new session to keep both modes' results separate"],"exampleFix":"// before: session ran with --commit abc123\nocr review --resume <id> --from main --to HEAD  // mismatch\n// after\nocr review --resume <id> --commit abc123","handlingStrategy":"validation","validationCode":"// read reviewMode from the session JSONL and require it to match before resuming\nif storedMode != requestedMode { /* abort resume; start fresh in requested mode */ }","typeGuard":null,"tryCatchPattern":"if err := state.ValidateOptions(opts); err != nil {\n\tif strings.Contains(err.Error(), \"does not match current mode\") {\n\t\treturn fmt.Errorf(\"%w; rerun with the original session's flags\", err)\n\t}\n\treturn err\n}","preventionTips":["Record and reuse the exact CLI flags of the original run when resuming","Keep one session id per review mode","Don't switch between --commit and --from/--to under the same --resume id"],"tags":["go","resume","validation","mode-mismatch"],"backgroundTag":"resume-mode-mismatch","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}