{"record":{"id":"48705298dd92bb48","repo":"alibaba/open-code-review","slug":"max-git-procs-must-be-a-non-negative-integer-0","errorCode":null,"errorMessage":"--max-git-procs must be a non-negative integer (0 means use default 16)","messagePattern":"--max-git-procs must be a non-negative integer \\(0 means use default 16\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/shared_flags.go","lineNumber":148,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"--max-git-procs must be a non-negative integer (0 means use default 16)\")\n\t}\n\tif opts.maxTokens < 0 {\n\t\treturn fmt.Errorf(\"--max-tokens must be a non-negative integer (0 means use configured or template default)\")\n\t}\n\tif opts.maxTokensBudget < 0 {\n\t\treturn fmt.Errorf(\"--max-tokens-budget must be a non-negative integer (0 means unlimited)\")\n\t}\n\tif opts.effort != \"\" {\n\t\tif _, err := template.ParseEffort(opts.effort); err != nil {\n\t\t\treturn fmt.Errorf(\"--effort: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateScanOptions(opts *scanOptions) error {\n\tif err := validateAudience(opts.audience); err != nil {\n\t\treturn err","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/shared_flags.go#L130-L166","documentation":"validateReviewOptions guard: the --max-git-procs flag was given a negative number. It controls the concurrency limit for git subprocesses; only 0 (use the default of 16) or a positive integer is meaningful, so negative input is rejected before execution.","triggerScenarios":"Passing --max-git-procs -2 (or any negative) to review — the opts.maxGitProcs < 0 branch, from the review command's anonymous option-building caller.","commonSituations":"Script arithmetic on a concurrency knob going negative; copying a negative from a 'disable parallelism' habit that this flag does not support; environment-derived values like MAX_PROCS unset/invalid.","solutions":["Pass a non-negative value; use --max-git-procs 0 for the default of 16","Clamp: MAX_GIT_PROCS=$(( value < 0 ? 0 : value )) in your wrapper","Fix the env/config source feeding the negative value","Omit the flag to accept the default"],"exampleFix":"// before\nocr review --from main --to HEAD --max-git-procs -1\n// after\nocr review --from main --to HEAD --max-git-procs 0   # 0 = default 16","handlingStrategy":"validation","validationCode":"case \"$MAX_GIT_PROCS\" in ''|*[!0-9]*) echo \"max-git-procs must be a non-negative integer, got: $MAX_GIT_PROCS\"; exit 2;; esac","typeGuard":"function isNonNegativeInt(v) { return Number.isInteger(v) && v >= 0; }","tryCatchPattern":"ocr review --max-git-procs \"$MAX_GIT_PROCS\" 2>err.log || { grep -q 'max-git-procs must be a non-negative' err.log && ocr review --max-git-procs 0; }","preventionTips":["Use 0 to mean 'default (16)'; there is no negative sentinel","Clamp any arithmetic that derives this value","Guard env-sourced values before passing them through","Omit the flag unless tuning concurrency is needed"],"tags":["cli","flags","validation","numeric"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}