FasterXML/jackson-databind · error · IllegalArgumentException

maxProblems must be positive, was: {}

Error message

maxProblems must be positive, was: {}

What it means

Thrown by the CollectingProblemHandler constructor when maxProblems is zero or negative. The handler collects deserialization problems up to a cap, so a non-positive cap is meaningless and rejected as a configuration error.

Source

Thrown at src/main/java/tools/jackson/databind/deser/CollectingProblemHandler.java:110

     * Maximum number of problems to collect before stopping.
     */
    private final int _maxProblems;

    /**
     * Constructs a handler with the default maximum problem limit.
     */
    public CollectingProblemHandler() {
        this(DEFAULT_MAX_PROBLEMS);
    }

    /**
     * Constructs a handler with a specific maximum problem limit.
     *
     * @param maxProblems Maximum number of problems to collect (must be positive)
     */
    public CollectingProblemHandler(int maxProblems) {
        if (maxProblems <= 0) {
            throw new IllegalArgumentException("maxProblems must be positive, was: " + maxProblems);
        }
        _maxProblems = maxProblems;
    }

    /**
     * Gets the maximum number of problems this handler will collect.
     */
    public int getMaxProblems() {
        return _maxProblems;
    }

    /**
     * Retrieves the problem collection bucket from context attributes.
     *
     * @return Problem bucket, or null if not in collecting mode
     */
    @SuppressWarnings("unchecked")
    public static List<CollectedProblem> getBucket(DeserializationContext ctxt) {

View on GitHub (pinned to a50c7d2a1d)

Solutions

  1. Pass a positive integer (e.g. 100 or 1000) to the constructor.
  2. Validate/sanitize the configured value (Math.max(1, configured)) before constructing the handler.
  3. Use the no-arg constructor to get DEFAULT_MAX_PROBLEMS if you don't need a custom cap.

Example fix

// before
new CollectingProblemHandler(0) // throws
// after
new CollectingProblemHandler(Math.max(1, configuredCap))
Defensive patterns

Strategy: validation

Validate before calling

int cap = configuredMaxProblems;
if (cap <= 0) cap = CollectingProblemHandler.DEFAULT_MAX_PROBLEMS;
new CollectingProblemHandler(cap);

Prevention

When it happens

Trigger: Calling new CollectingProblemHandler(0), new CollectingProblemHandler(-1), or passing a computed value that resolved to <= 0.

Common situations: Configuring the cap from a properties file where the value was missing or unparseable (defaulting to 0); arithmetic that produced a negative; copy-pasting a constant incorrectly.

Related errors


AI-assisted analysis of FasterXML/jackson-databind@a50c7d2a1d (2026-08-06). Data as JSON: /api/errors/0d169baecd391e36. Report an issue: GitHub.