Provide a clearer JsonException message when HttpTransporter receives invalid response.#766
Open
arbazargani wants to merge 1 commit intoopenai-php:mainfrom
Open
Provide a clearer JsonException message when HttpTransporter receives invalid response.#766arbazargani wants to merge 1 commit intoopenai-php:mainfrom
arbazargani wants to merge 1 commit intoopenai-php:mainfrom
Conversation
… invalid response.
Collaborator
|
At the moment not really feeling the use for this. The |
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.
Fix handling of invalid response.
What:
Description:
This PR improves the error handling in
HttpTransporterwhen an invalid or malformed response is returned by the service provider.Previously, such cases could result in unclear or misleading exceptions. In scenarios where the service provider returned a non-JSON response (such as an HTML error page like
403 Forbiddenfrom nginx, or a CDN-blocked request), the client would typically throw a genericsyntax error, which made it difficult to understand the root cause.This change ensures that a proper
JsonExceptionis thrown with a more descriptive and accurate error message, making debugging easier and behavior more predictable. It explicitly handles cases where the response body is not valid JSON and provides clearer insight into what actually went wrong.Related:
N/A