Skip to content

GH-5832: Fix StructuredOutputValidationAdvisor to validate all results#5833

Closed
ArpanC6 wants to merge 2 commits intospring-projects:mainfrom
ArpanC6:main
Closed

GH-5832: Fix StructuredOutputValidationAdvisor to validate all results#5833
ArpanC6 wants to merge 2 commits intospring-projects:mainfrom
ArpanC6:main

Conversation

@ArpanC6
Copy link
Copy Markdown

@ArpanC6 ArpanC6 commented Apr 20, 2026

What

Fixes validateOutputSchema() to validate all results in a ChatResponse
instead of only the first one.

Why

ChatResponse.getResult() returns only the first result. When multiple results
exist, the remaining ones were silently skipped invalid JSON could pass
validation undetected.

Addresses the TODO comment on line 191:
// TODO: should we consider validation for multiple results?

How

Replaced getResult() with getResults() and added a loop to validate each
result individually. Returns the first validation failure encountered.

Closes #5832

…first one

Signed-off-by: Arpan Chakraborty <chakrabortyarpan151@gmail.com>
@ArpanC6
Copy link
Copy Markdown
Author

ArpanC6 commented Apr 20, 2026

I've submitted a pull request for this issue #5833

…xSseServerTransportProvider

Signed-off-by: Arpan Chakraborty <chakrabortyarpan151@gmail.com>
@redinside-dev
Copy link
Copy Markdown

Note: This PR (#5833) is a duplicate of #5846 which is already under review and approved. Both address the same TODO: replacing getResult() with getResults() in validateOutputSchema(). Please close #5833 in favor of #5846 which has more test coverage.

@ArpanC6
Copy link
Copy Markdown
Author

ArpanC6 commented Apr 22, 2026

Thank you for the heads up. I wasn't aware of PR #5846. Closing this in favor of that PR.

@ArpanC6 ArpanC6 closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StructuredOutputValidationAdvisor validates only first result, ignoring remaining results

2 participants