alibaba/open-code-review · error
resume session scan path scope %q does not match current sco
Error message
resume session scan path scope %q does not match current scope %q
What it means
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.
Source
Thrown at internal/session/resume.go:306
return fmt.Errorf("resume mode %q is not supported", opts.ReviewMode)
}
return nil
}
// ValidateScanOptions verifies that the previous session was a full-file scan.
func (s *ResumeState) ValidateScanOptions(scanPaths []string) error {
if s == nil {
return nil
}
if s.ReviewMode == "" {
return fmt.Errorf("resume session %q is missing review mode metadata", s.SessionID)
}
if s.ReviewMode != ReviewModeFullScan {
return fmt.Errorf("resume session review mode %q does not match current mode %q", s.ReviewMode, ReviewModeFullScan)
}
current := normalizeScanPaths(scanPaths)
if s.HasScanPathScope && !equalStringSlices(s.ScanPaths, current) {
return fmt.Errorf("resume session scan path scope %q does not match current scope %q", formatScanScope(s.ScanPaths), formatScanScope(current))
}
return nil
}
func normalizeScanPaths(paths []string) []string {
if len(paths) == 0 {
return nil
}
out := make([]string, 0, len(paths))
seen := make(map[string]struct{}, len(paths))
for _, p := range paths {
p = strings.TrimSpace(p)
p = strings.TrimPrefix(p, "./")
p = strings.TrimSuffix(filepath.ToSlash(p), "/")
if p == "" {
continue
}
if _, ok := seen[p]; ok {View on GitHub (pinned to 5cf97d0d15)
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
Example fix
// before: session scanned pkg/a,pkg/b ocr scan --resume <id> pkg/a // after ocr scan --resume <id> pkg/a pkg/b
Defensive patterns
Strategy: validation
Validate before calling
// normalize and compare scope before resuming
norm := func(ps []string) []string { /* trim, drop ./ and trailing /, dedupe, sort */ }
if !slices.Equal(storedPaths, norm(requestedPaths)) { /* scope differs; start a new session */ } Try / catch
if err := state.ValidateScanOptions(scanPaths); err != nil {
if strings.Contains(err.Error(), "scan path scope") {
return runFreshScan(scanPaths) // different scope: reuse would be unsound
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- [ocr] WARNING: skipping %s (%d bytes exceeds %d-byte scan li
- scan failed: %w
- load resume session: %w (run 'ocr session list' to see avail
- %w (run 'ocr session list' to see available sessions)
- resume session %q has no completed scan items (run 'ocr sess
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/d47778b03a738e00.
Report an issue: GitHub.