{"record":{"id":"6bbb57dd19ac07cd","repo":"alibaba/open-code-review","slug":"resume-session-q-is-missing-review-mode-metadata","errorCode":null,"errorMessage":"resume session %q is missing review mode metadata","messagePattern":"resume session %q is missing review mode metadata","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/session/resume.go","lineNumber":282,"sourceCode":"\t}\n\treturn out\n}\n\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}","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/session/resume.go#L264-L300","documentation":"ResumeState.ValidateOptions rejects when the replayed session state carries an empty ReviewMode — i.e. the prior session's JSONL never recorded a session_start with reviewMode metadata. The library cannot verify mode compatibility without it.","triggerScenarios":"Resuming a legacy session file written before reviewMode was persisted in session_start records, or a session file whose only records are checkpoints with no session_start line (truncated very early).","commonSituations":"Upgrading open-code-review across versions and resuming a pre-metadata session file; a session file truncated before its first session_start record was flushed.","solutions":["Start a fresh review for that old session; legacy files carry no mode metadata to validate","Regenerate a session by running a new review in the desired mode, then resume that","Do not hand-edit the JSONL to inject reviewMode — fingerprints were computed under unknown semantics"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// peek the first session_start record before resuming legacy files\nhasMode := false\nfor _, line := range firstLines(path, 5) {\n\tvar rec map[string]any\n\tif json.Unmarshal(line, &rec) == nil && rec[\"reviewMode\"] != nil { hasMode = true; break }\n}\nif !hasMode { /* legacy file: don't resume */ }","typeGuard":null,"tryCatchPattern":"if err := state.ValidateOptions(opts); err != nil {\n\tif strings.Contains(err.Error(), \"missing review mode metadata\") {\n\t\treturn runFresh(opts) // legacy session\n\t}\n\treturn err\n}","preventionTips":["Upgrade sessions wholesale: after a tool version bump, start fresh rather than resuming old session files","Treat sessions without a session_start record as unusable for resume"],"tags":["go","resume","legacy","metadata"],"backgroundTag":"missing-session-metadata","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}