Skip to content

[HttpClient] Fix Array to string conversion notice when parsing JSON error body with non-scalar detail property #38122

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

Merged
merged 1 commit into from
Sep 9, 2020

Conversation

emarref
Copy link
Contributor

@emarref emarref commented Sep 9, 2020

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.

@nicolas-grekas nicolas-grekas changed the title Fix Array to string conversion notice when parsing JSON error body with non-scalar detail property. [HttpClient] Fix Array to string conversion notice when parsing JSON error body with non-scalar detail property Sep 9, 2020
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Sep 9, 2020
@nicolas-grekas
Copy link
Member

Thank you @emarref.

@nicolas-grekas nicolas-grekas merged commit 9bb8084 into symfony:4.4 Sep 9, 2020
@emarref emarref deleted the ticket_38118 branch September 9, 2020 23:02
This was referenced Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants