{"record":{"id":"40358bb1cb2def52","repo":"alibaba/open-code-review","slug":"resume-session-q-has-no-completed-scan-items-run","errorCode":null,"errorMessage":"resume session %q has no completed scan items (run 'ocr session list' to see available sessions)","messagePattern":"resume session %q has no completed scan items \\(run 'ocr session list' to see available sessions\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/scan_cmd.go","lineNumber":261,"sourceCode":"\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})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"scan preview failed: %w\", err)\n\t}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/scan_cmd.go#L243-L279","documentation":"A loaded resume state may legitimately contain zero completed scan items (every item failed or was retracted by review_item_failed). Resuming such a session has nothing to skip, so loadScanResumeState refuses with \"resume session %q has no completed scan items\". The scan cannot make progress from this checkpoint.","triggerScenarios":"Running `ocr scan --resume <id>` where the session's JSONL contains no surviving review_item_done/review_item_reused records — all files failed, or failures retracted earlier completions.","commonSituations":"Resuming a scan that crashed on the very first file; a session where every attempt hit an LLM/network error so nothing was ever marked done; resuming an already fully-completed-and-retracted session.","solutions":["Start a fresh `ocr scan` — there is nothing to resume from this session.","Investigate why the original scan completed nothing (check provider auth/network via `ocr session show <id>` items).","Pick a different session id from `ocr session list` that has completed items."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"state, err := session.LoadResumeState(repoDir, opts.resume)\nif err == nil && state.CompletedCount() == 0 {\n    return fmt.Errorf(\"session %s has no completed items; run a fresh scan\", opts.resume)\n}","typeGuard":"func resumable(s *session.ResumeState) bool {\n    return s != nil && s.CompletedCount() > 0\n}","tryCatchPattern":"state, err := loadScanResumeState(repoDir, opts, scanPaths)\nif err != nil {\n    log.Printf(\"resume unavailable (%v); starting fresh scan\", err)\n    return executeScanFresh(opts) // fallback path\n}","preventionTips":["Check `ocr session show <id>` item statuses before resuming.","If the original scan completed nothing, fix the root cause (auth/network) first.","Treat a zero-item resume as a signal to start fresh, not to retry blindly."],"tags":["go","cli","session","resume"],"backgroundTag":"empty-resume-checkpoint","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}