Fix BeanOutputConverter List type format mismatch#5795
Open
ehdgusdl wants to merge 2 commits intospring-projects:mainfrom
Open
Fix BeanOutputConverter List type format mismatch#5795ehdgusdl wants to merge 2 commits intospring-projects:mainfrom
ehdgusdl wants to merge 2 commits intospring-projects:mainfrom
Conversation
added 2 commits
April 13, 2026 03:16
When the target type is a List, some LLMs mirror the JSON schema structure
and return {"type":"array","items":[...]} instead of a plain array [...].
This causes a MismatchedInputException during deserialization.
Extract the array from the "items" key when the response matches the
schema-shaped pattern with "type":"array" and "items" as an array.
Closes spring-projects#5707
Signed-off-by: DHKim7762 <kim138762@gmail.com>
…ndling
- convertListTypeFromSchemaShapedResponse: verify correct extraction
from {"type":"array","items":[...]} responses
- convertListTypeFromSchemaShapedResponseWithEmptyArray: verify empty
array edge case
- convertListTypeIgnoresObjectWithItemsField: verify the fix does not
trigger when "type" is not "array"
Signed-off-by: DHKim7762 <kim138762@gmail.com>
350bf21 to
6102312
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BeanOutputConverter.convert()to handle schema-shaped LLM responses for List typesList, some LLMs mirror the JSON schema structure and return{"type":"array","items":[...]}instead of a plain array[...], causing aMismatchedInputException"items"key when the response matches the schema-shaped patternCloses #5707
Changes
BeanOutputConverter.javaconvert(): when the target type isListand the response is an object with"type":"array"and"items"as an array, extract the array for deserializationisListType()helper to check whether the target type is aListor subtypeBeanOutputConverterTest.javaconvertListTypeFromSchemaShapedResponse: verifies correct extraction from{"type":"array","items":[...]}convertListTypeFromSchemaShapedResponseWithEmptyArray: verifies empty array edge caseconvertListTypeIgnoresObjectWithItemsField: verifies the fix does not trigger when"type"is not"array"Test plan
convertTypeReferenceArraytest still passes (no regression for normal array responses)BeanOutputConverterTestsuite passes