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 err

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Pass a non-negative value; use --max-git-procs 0 for the default of 16
  2. Clamp: MAX_GIT_PROCS=$(( value < 0 ? 0 : value )) in your wrapper
  3. Fix the env/config source feeding the negative value
  4. 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

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


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/48705298dd92bb48. Report an issue: GitHub.