{"record":{"id":"6556bd89d8b2347e","repo":"FasterXML/jackson-databind","slug":"d-deserialization-problems-s-showing-first-5-n","errorCode":null,"errorMessage":"%d deserialization problems%s (showing first 5):%n%s","messagePattern":"(.+?) deserialization problems(.+?) \\(showing first 5\\):%n(.+?)","errorType":"exception","errorClass":"DeferredBindingException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/ObjectReader.java","lineNumber":1933,"sourceCode":"        int maxProblems = CollectingProblemHandler.DEFAULT_MAX_PROBLEMS;\n        LinkedNode<DeserializationProblemHandler> handlers = _config.getProblemHandlers();\n        while (handlers != null) {\n            if (handlers.value() instanceof CollectingProblemHandler cph) {\n                maxProblems = cph.getMaxProblems();\n                break;\n            }\n            handlers = handlers.next();\n        }\n\n        try {\n            // Directly invoke _bind with the prepared context\n            @SuppressWarnings(\"unchecked\")\n            T result = (T) _bind(ctxt, p, _valueToUpdate);\n\n            // Check if any problems were collected\n            if (!bucket.isEmpty()) {\n                boolean limitReached = (bucket.size() >= maxProblems);\n                throw new DeferredBindingException(p, bucket, limitReached);\n            }\n\n            return result;\n\n        } catch (DeferredBindingException e) {\n            throw e; // Already properly formatted\n\n        } catch (DatabindException e) {\n            // Hard failure occurred; attach collected problems as suppressed\n            if (!bucket.isEmpty()) {\n                boolean limitReached = (bucket.size() >= maxProblems);\n                if (limitReached) {\n                    // Limit was hit - throw DeferredBindingException as primary exception\n                    DeferredBindingException dbe = new DeferredBindingException(p, bucket, true);\n                    dbe.addSuppressed(e); // Original error as suppressed for debugging\n                    throw dbe;\n                } else {\n                    // Hard failure unrelated to limit - keep original as primary","sourceCodeStart":1915,"sourceCodeEnd":1951,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/ObjectReader.java#L1915-L1951","documentation":"This is the user-facing message of a DeferredBindingException thrown by ObjectReader when using a problemCollectingReader() and multiple deserialization problems were collected during a single read operation. Rather than failing on the first error, the collecting reader buffers up to maxProblems errors and then throws this exception with a summary showing the total count, whether the limit was reached, and the first 5 problem messages with their paths.","triggerScenarios":"Calling readValue() on an ObjectReader obtained via problemCollectingReader() / problemCollectingReader(int) on JSON input that contains multiple field-level deserialization errors (wrong types, missing required fields, bad formats). The exception message is generated in DeferredBindingException.formatMessage() and the throw happens at ObjectReader._bindWithProblemCollection():1933.","commonSituations":"Bulk-importing JSON data where you want to see all validation errors at once rather than fixing them one at a time. API request validation where you want to report all field errors to the caller. Processing user-uploaded data files with expected format issues.","solutions":["Inspect DeferredBindingException.getProblems() to get the full structured list of CollectedProblem objects, not just the message string.","Fix the underlying input data issues identified by each problem's path and message.","Increase maxProblems via problemCollectingReader(largerValue) if you need to see more than the current limit.","If you need to process partially-valid data, use a tree model (readTree) and validate field-by-field with error tolerance instead of direct POJO binding."],"exampleFix":"// before: only see message\ntry {\n    reader.readValue(json, MyType.class);\n} catch (DeferredBindingException e) {\n    log.error(e.getMessage()); // only first 5 in text\n}\n// after: inspect all problems programmatically\ntry {\n    reader.readValue(json, MyType.class);\n} catch (DeferredBindingException e) {\n    for (CollectedProblem p : e.getProblems()) {\n        log.warn(\"{}: {}\", p.getPath(), p.getMessage());\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    MyType result = collectingReader.readValue(json, MyType.class);\n} catch (DeferredBindingException e) {\n    List<CollectedProblem> problems = e.getProblems();\n    // report all problems to the caller, log them, or collect for batch retry\n    for (CollectedProblem p : problems) {\n        response.addFieldError(p.getPath(), p.getMessage());\n    }\n}","preventionTips":["Catch DeferredBindingException specifically (not generic Exception) to access getProblems().","Use a sufficiently high maxProblems to see all errors in one pass.","Validate input structure before POJO binding if you expect many errors."],"tags":["deferred-binding","problem-collection","deserialization","objectreader","validation"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}