{"record":{"id":"0d169baecd391e36","repo":"FasterXML/jackson-databind","slug":"maxproblems-must-be-positive-was","errorCode":null,"errorMessage":"maxProblems must be positive, was: {}","messagePattern":"maxProblems must be positive, was: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/CollectingProblemHandler.java","lineNumber":110,"sourceCode":"     * Maximum number of problems to collect before stopping.\n     */\n    private final int _maxProblems;\n\n    /**\n     * Constructs a handler with the default maximum problem limit.\n     */\n    public CollectingProblemHandler() {\n        this(DEFAULT_MAX_PROBLEMS);\n    }\n\n    /**\n     * Constructs a handler with a specific maximum problem limit.\n     *\n     * @param maxProblems Maximum number of problems to collect (must be positive)\n     */\n    public CollectingProblemHandler(int maxProblems) {\n        if (maxProblems <= 0) {\n            throw new IllegalArgumentException(\"maxProblems must be positive, was: \" + maxProblems);\n        }\n        _maxProblems = maxProblems;\n    }\n\n    /**\n     * Gets the maximum number of problems this handler will collect.\n     */\n    public int getMaxProblems() {\n        return _maxProblems;\n    }\n\n    /**\n     * Retrieves the problem collection bucket from context attributes.\n     *\n     * @return Problem bucket, or null if not in collecting mode\n     */\n    @SuppressWarnings(\"unchecked\")\n    public static List<CollectedProblem> getBucket(DeserializationContext ctxt) {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/CollectingProblemHandler.java#L92-L128","documentation":"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.","triggerScenarios":"Calling new CollectingProblemHandler(0), new CollectingProblemHandler(-1), or passing a computed value that resolved to <= 0.","commonSituations":"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.","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."],"exampleFix":"// before\nnew CollectingProblemHandler(0) // throws\n// after\nnew CollectingProblemHandler(Math.max(1, configuredCap))","handlingStrategy":"validation","validationCode":"int cap = configuredMaxProblems;\nif (cap <= 0) cap = CollectingProblemHandler.DEFAULT_MAX_PROBLEMS;\nnew CollectingProblemHandler(cap);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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)."],"tags":["configuration","validation","problem-handler"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}