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
- Pass a positive integer (e.g. 100 or 1000) to the constructor.
- Validate/sanitize the configured value (Math.max(1, configured)) before constructing the handler.
- 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
- Clamp externalized config values to a positive minimum.
- Prefer the no-arg constructor unless you need a specific cap.
- Unit-test handler construction with edge-case inputs (0, negative, large).
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
- maxProblems must be positive
- Cannot set maxDeserializerCacheSize to a negative value
- Cannot set maxSerializerCacheSize to a negative value
- Cannot set maxTypeFactoryCacheSize to a negative value
- AnnotationIntrospector returned Converter definition of type
AI-assisted analysis of FasterXML/jackson-databind@a50c7d2a1d (2026-08-06).
Data as JSON: /api/errors/0d169baecd391e36.
Report an issue: GitHub.