{"record":{"id":"7d068c3188950dbb","repo":"alibaba/open-code-review","slug":"preview-and-resume-cannot-be-used-together","errorCode":null,"errorMessage":"--preview and --resume cannot be used together","messagePattern":"--preview and --resume cannot be used together","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/shared_flags.go","lineNumber":129,"sourceCode":"\t}\n}\n\nfunc validateOutputFormat(format string) (string, error) {\n\tnormalized := strings.ToLower(strings.TrimSpace(format))\n\tswitch normalized {\n\tcase \"text\", \"json\", \"sarif\":\n\t\treturn normalized, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"invalid --format value %q: must be 'text', 'json', or 'sarif'\", format)\n\t}\n}\n\nfunc validateReviewOptions(opts *reviewOptions) error {\n\tif err := validateDiffMode(opts.from, opts.to, opts.commit); err != nil {\n\t\treturn err\n\t}\n\tif opts.preview && opts.resume != \"\" {\n\t\treturn fmt.Errorf(\"--preview and --resume cannot be used together\")\n\t}\n\tif err := validateAudience(opts.audience); err != nil {\n\t\treturn err\n\t}\n\tnormalizedFormat, err := validateOutputFormat(opts.outputFormat)\n\tif err != nil {\n\t\treturn err\n\t}\n\topts.outputFormat = normalizedFormat\n\tconst minMaxTools = 50\n\tif opts.maxTools < 0 {\n\t\treturn fmt.Errorf(\"--max-tools must be a non-negative integer (0 means use template default)\")\n\t}\n\tif opts.maxTools > 0 && opts.maxTools < minMaxTools {\n\t\tfmt.Fprintf(os.Stderr, \"[ocr] --max-tools %d is below minimum %d, using %d\\n\", opts.maxTools, minMaxTools, minMaxTools)\n\t\topts.maxTools = minMaxTools\n\t}\n\tif opts.maxGitProcs < 0 {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/shared_flags.go#L111-L147","documentation":"validateReviewOptions rejects combining --preview with --resume because they configure contradictory session behavior: preview runs a fresh lightweight pass while resume continues an existing session identified by an ID.","triggerScenarios":"Running `ocr review --preview --resume <id>` — the opts.preview && opts.resume != \"\" branch, reached from the review subcommand's anonymous option-building caller.","commonSituations":"Shell aliases or wrappers that hardcode --preview while the user adds --resume; scripts reusing a flag array across modes; misunderstanding preview as compatible with session continuation.","solutions":["Drop --preview to resume the session: ocr review --resume <id>","Drop --resume to run a fresh preview: ocr review --preview ...","In wrappers, make --preview and --resume mutually exclusive in your own arg parsing","Start a new session instead of resuming if preview semantics are what you want"],"exampleFix":"// before\nocr review --from main --to HEAD --preview --resume sess_123\n// after\nocr review --from main --to HEAD --resume sess_123","handlingStrategy":"validation","validationCode":"if [ -n \"$RESUME\" ] && [ \"$PREVIEW\" = \"1\" ]; then echo '--preview and --resume are mutually exclusive'; exit 2; fi","typeGuard":"null","tryCatchPattern":"if ! ocr review \"$@\" 2>err.log; then grep -q 'preview and --resume cannot be used together' err.log && echo 'Drop --preview or --resume'; fi","preventionTips":["Treat --preview and --resume as exclusive modes in your own arg parser","Build flag arrays per mode instead of appending globally","Document in wrapper scripts which mode each alias uses","Resume existing sessions without preview; use preview only for fresh runs"],"tags":["cli","flags","validation"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}