-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] HttpExceptionTrait Misinterprets error response #38118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Thanks for the report. Would you like to send a fix? |
Yeah I'll have a crack at a fix. |
nicolas-grekas
added a commit
that referenced
this issue
Sep 9, 2020
…rsing JSON error body with non-scalar detail property (emarref) This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpClient] Fix Array to string conversion notice when parsing JSON error body with non-scalar detail property | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #38118 | License | MIT | Doc PR | no An earlier commit added the ability to detect common API formats and extract a useful error message from the error response payload. To achieve this, if a `title` and `detail` property are found in the error response, the response is considered to be in a known format (RFC 7807) and these values are concatenated to form a helpful error message. However, when either `title` or `detail` property are present, but the document is not intended to follow the RFC semantics, if the properties are not scalar (e.g. if the detail property is an array of field validation violations) then the concatenation of the strings causes a notice to be raised. This pull request checks that the `title` and `detail` properties are scalar before attempting to concatenate them. If they are not, no enhanced error message is provided. Commits ------- 76fa884 [HttpClient] Fix Array to string conversion notice when parsing JSON error body with non-scalar detail property
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected: 4.4.12
Description
I am using the HTTP client to query a third party API. I am making a call that results in a 400 Bad Request response, and the response looks like this:
However the HTTP Client sees the detail property and assumes the response is in RFC 7807 format, and attempts to concatenate the detail with other strings.
The detail property is an object which causes an
Array to string conversion
error, preventing the response from being returned to application code.How to reproduce
Use HTTP Client to make a request that results in a
400 Bad Request
response, and returns a json payload with a non-scalartitle
ordetail
property.The text was updated successfully, but these errors were encountered: