multica-ai/multica · error

max_concurrent_tasks must be >= 0 (got %d)

Error message

max_concurrent_tasks must be >= 0 (got %d)

What it means

After parsing max_concurrent_tasks as an integer, applyConfigSet enforces a non-negative lower bound. A negative integer (e.g. -1) parses fine but is rejected because a negative concurrency cap is meaningless for the daemon.

Source

Thrown at server/cmd/multica/cmd_config.go:186

			cfg.WorkspacesRoot = ""
			return nil
		}
		root, err := filepath.Abs(value)
		if err != nil {
			return fmt.Errorf("resolve workspaces_root: %w", err)
		}
		cfg.WorkspacesRoot = root
	case "max_concurrent_tasks":
		if value == "" {
			cfg.MaxConcurrentTasks = 0
			return nil
		}
		n, err := strconv.Atoi(value)
		if err != nil {
			return fmt.Errorf("max_concurrent_tasks must be an integer: %w", err)
		}
		if n < 0 {
			return fmt.Errorf("max_concurrent_tasks must be >= 0 (got %d)", n)
		}
		cfg.MaxConcurrentTasks = n
	case "poll_interval":
		if value == "" {
			cfg.PollInterval = ""
			return nil
		}
		d, err := time.ParseDuration(value)
		if err != nil {
			return fmt.Errorf("poll_interval must be a Go duration (e.g. 10s, 500ms): %w", err)
		}
		// Reject zero and negative durations. Persisting "0s" would look
		// configured in `config show` but be silently ignored at daemon
		// start (the resolver only substitutes strictly positive values),
		// which is exactly the trap reported in #3824's review. Empty
		// string is the one and only way to clear a previously persisted
		// value.
		if d <= 0 {

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Set a value >= 0 (0 disables the cap / means unset in this config's semantics).
  2. Fix the script arithmetic that produced the negative number (clamp with a max/abs guard).

Example fix

# before
multica config set max_concurrent_tasks "$(( TOTAL - RESERVED ))"  # can go negative
# after
multica config set max_concurrent_tasks "$(( TOTAL - RESERVED > 0 ? TOTAL - RESERVED : 0 ))"
Defensive patterns

Strategy: validation

Validate before calling

# clamp before setting
VAL=$(( VAL < 0 ? 0 : VAL ))
multica config set max_concurrent_tasks "$VAL"

Prevention

When it happens

Trigger: `multica config set max_concurrent_tasks -1` or `-5`, often from shell arithmetic that subtracts (e.g. $TOTAL - $RESERVED going below zero).

Common situations: Computed values in scripts going negative when inputs shrink; '-1 = unlimited' conventions from other tools mistakenly applied here.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/bca95f2488a6748a. Report an issue: GitHub.