alibaba/open-code-review · error
--max-git-procs must be a non-negative integer (0 means use
Error message
--max-git-procs must be a non-negative integer (0 means use default 16)
What it means
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.
Source
Thrown at cmd/opencodereview/shared_flags.go:148
}
if err := validateAudience(opts.audience); err != nil {
return err
}
normalizedFormat, err := validateOutputFormat(opts.outputFormat)
if err != nil {
return err
}
opts.outputFormat = normalizedFormat
const minMaxTools = 50
if opts.maxTools < 0 {
return fmt.Errorf("--max-tools must be a non-negative integer (0 means use template default)")
}
if opts.maxTools > 0 && opts.maxTools < minMaxTools {
fmt.Fprintf(os.Stderr, "[ocr] --max-tools %d is below minimum %d, using %d\n", opts.maxTools, minMaxTools, minMaxTools)
opts.maxTools = minMaxTools
}
if opts.maxGitProcs < 0 {
return fmt.Errorf("--max-git-procs must be a non-negative integer (0 means use default 16)")
}
if opts.maxTokens < 0 {
return fmt.Errorf("--max-tokens must be a non-negative integer (0 means use configured or template default)")
}
if opts.maxTokensBudget < 0 {
return fmt.Errorf("--max-tokens-budget must be a non-negative integer (0 means unlimited)")
}
if opts.effort != "" {
if _, err := template.ParseEffort(opts.effort); err != nil {
return fmt.Errorf("--effort: %w", err)
}
}
return nil
}
func validateScanOptions(opts *scanOptions) error {
if err := validateAudience(opts.audience); err != nil {
return errView on GitHub (pinned to 5cf97d0d15)
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
Example fix
// before ocr review --from main --to HEAD --max-git-procs -1 // after ocr review --from main --to HEAD --max-git-procs 0 # 0 = default 16
Defensive patterns
Strategy: validation
Validate before calling
case "$MAX_GIT_PROCS" in ''|*[!0-9]*) echo "max-git-procs must be a non-negative integer, got: $MAX_GIT_PROCS"; exit 2;; esac
Type guard
function isNonNegativeInt(v) { return Number.isInteger(v) && v >= 0; } Try / catch
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; } Prevention
- 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
When it happens
Trigger: Passing --max-git-procs -2 (or any negative) to review — the opts.maxGitProcs < 0 branch, from the review command's anonymous option-building caller.
Common situations: 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.
Related errors
- --max-tools must be a non-negative integer (0 means use temp
- --max-tokens must be a non-negative integer (0 means use con
- only one review mode allowed (--from/--to or --commit)
- --to is required when --from is specified
- --from is required when --to is specified
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/48705298dd92bb48.
Report an issue: GitHub.