Fix #772: Improve OpenAI error messages with user-friendly parsing and hints #3869
+303
−1
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
This PR improves OpenAI API error messages by implementing structured JSON parsing and providing user-friendly error messages with contextual hints, addressing issue #772.
Problem
Previously, OpenAI API errors were displayed in raw JSON format, making them difficult for users to understand:
Before:
Solution
The error messages are now parsed and displayed in a user-friendly format with helpful hints:
After:
Changes Made
New Classes
OpenAiErrorResponse
: POJO for parsing OpenAI JSON error response structureOpenAiErrorMessageImprover
: Utility class for improving error messages with:Dependencies
spring-boot-starter-json
dependency tospring-ai-retry
module for Jackson JSON processingError Message Improvements
Testing
Related Issues
Resolves #772: OpenAI - improve error messages when there is a connection error