{"record":{"id":"d47778b03a738e00","repo":"alibaba/open-code-review","slug":"resume-session-scan-path-scope-q-does-not-match-c","errorCode":null,"errorMessage":"resume session scan path scope %q does not match current scope %q","messagePattern":"resume session scan path scope %q does not match current scope %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/session/resume.go","lineNumber":306,"sourceCode":"\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}\n\tcurrent := normalizeScanPaths(scanPaths)\n\tif s.HasScanPathScope && !equalStringSlices(s.ScanPaths, current) {\n\t\treturn fmt.Errorf(\"resume session scan path scope %q does not match current scope %q\", formatScanScope(s.ScanPaths), formatScanScope(current))\n\t}\n\treturn nil\n}\n\nfunc normalizeScanPaths(paths []string) []string {\n\tif len(paths) == 0 {\n\t\treturn nil\n\t}\n\tout := make([]string, 0, len(paths))\n\tseen := make(map[string]struct{}, len(paths))\n\tfor _, p := range paths {\n\t\tp = strings.TrimSpace(p)\n\t\tp = strings.TrimPrefix(p, \"./\")\n\t\tp = strings.TrimSuffix(filepath.ToSlash(p), \"/\")\n\t\tif p == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := seen[p]; ok {","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/session/resume.go#L288-L324","documentation":"ResumeState.ValidateScanOptions rejects when the previous session had an explicit scan-path scope (HasScanPathScope) and its normalized ScanPaths differ from the paths given now. Reusing results scoped to different path sets could silently miss files.","triggerScenarios":"Prior scan covered e.g. pkg/a,pkg/b but the new scan passes pkg/a or a different directory list; the session_start record stored scanPaths and they don't match after normalization.","commonSituations":"User scans a narrower/wider directory set than the original run and tries to reuse the same session; reordered or duplicate paths are fine (normalized), but genuinely different sets are not; CI matrix jobs pass different target dirs under one session id.","solutions":["Pass the same set of scan paths as the original session (normalization ignores ./ prefixes, trailing slashes, duplicates, order)","Start a new scan session for the different path scope","Drop the path scope (whole repo) only if the original had none"],"exampleFix":"// before: session scanned pkg/a,pkg/b\nocr scan --resume <id> pkg/a\n// after\nocr scan --resume <id> pkg/a pkg/b","handlingStrategy":"validation","validationCode":"// normalize and compare scope before resuming\nnorm := func(ps []string) []string { /* trim, drop ./ and trailing /, dedupe, sort */ }\nif !slices.Equal(storedPaths, norm(requestedPaths)) { /* scope differs; start a new session */ }","typeGuard":null,"tryCatchPattern":"if err := state.ValidateScanOptions(scanPaths); err != nil {\n\tif strings.Contains(err.Error(), \"scan path scope\") {\n\t\treturn runFreshScan(scanPaths) // different scope: reuse would be unsound\n\t}\n\treturn err\n}","preventionTips":["Reuse the same path list (order/duplicates don't matter — they are normalized) when resuming","Start a new session whenever the scan target set changes","In CI, derive scan paths deterministically so repeated jobs match the original scope"],"tags":["go","resume","scan","scope-mismatch"],"backgroundTag":"resume-scope-mismatch","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}