FasterXML/jackson-databind · error · IllegalArgumentException
maxProblems must be positive, was: ${maxProblems}
Error message
maxProblems must be positive, was: ${maxProblems} What it means
Thrown by the CollectingProblemHandler constructor when maxProblems is <= 0. This handler accumulates deserialization problems up to a cap; a non-positive cap is meaningless (it would collect nothing or be unbounded by mistake), so the constructor rejects it.
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 87876ca5c0)
Solutions
- Pass a strictly positive integer (e.g. CollectingProblemHandler.DEFAULT_MAX_PROBLEMS or a sensible cap like 100).
- Validate configuration before construction: if the configured limit is <= 0, fall back to the default.
- Treat 0/empty as 'use default' rather than passing it through.
Example fix
// before
int cap = config.getInt("max.problems", 0);
handler = new CollectingProblemHandler(cap);
// after
int cap = config.getInt("max.problems", CollectingProblemHandler.DEFAULT_MAX_PROBLEMS);
if (cap <= 0) cap = CollectingProblemHandler.DEFAULT_MAX_PROBLEMS;
handler = new CollectingProblemHandler(cap); Defensive patterns
Strategy: validation
Validate before calling
int cap = configuredMaxProblems; if (cap <= 0) cap = CollectingProblemHandler.DEFAULT_MAX_PROBLEMS; handler = new CollectingProblemHandler(cap);
Prevention
- Treat 0/negative as 'use default' rather than passing through.
- Bound the value to a sensible positive range from configuration.
- Unit-test problem-handler construction with edge-case config values.
When it happens
Trigger: Constructing new CollectingProblemHandler(0) or new CollectingProblemHandler(negative), or computing the cap from user input/configuration that resolves to zero or a negative number.
Common situations: Reading a 'max problems' limit from config where the default is unset (0); passing a size derived from a collection length that is empty; arithmetic that underflows; misinterpreting 0 as 'unlimited'.
Related errors
- Cannot pass null modifier
- Cannot pass null resolver
- Cannot pass null resolver
- Cannot deserialize Class ${type.getName()} (of type ${typeSt
- `DeserializationProblemHandler.handleNullForPrimitives()` fo
AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11).
Data as JSON: /api/errors/78d61cb6de82ab9a.
Report an issue: GitHub.