Skip to content

[Serializer] Fix exception thrown by YamlEncoder #59323

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
Jan 6, 2025

Conversation

VincentLanglet
Copy link
Contributor

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix the example given #59306 (comment)
License MIT

DecoderInterface::decode is supposed to throw scoped exception cf

* @throws UnexpectedValueException
*/
public function decode(string $data, string $format, array $context = []): mixed;

but the YamlEncoder::decode could throw ParseException.
Others similar Encoder, like XmlEncoder or JsonEncoder are throwing NotEncodableValue so I did the same cf example

try {
$encodedJson = json_encode($data, $options);
} catch (\JsonException $e) {
throw new NotEncodableValueException($e->getMessage(), 0, $e);
}

@carsonbot carsonbot added this to the 6.4 milestone Dec 29, 2024
@VincentLanglet VincentLanglet changed the title [Serializer] Fix a typo in NoPrivateNetworkHttpClient [Serializer] Fix exception thrown by YamlEncoder Dec 29, 2024
@VincentLanglet
Copy link
Contributor Author

I don't think UrlSanitizerTest errors are related...

@OskarStark OskarStark changed the title [Serializer] Fix exception thrown by YamlEncoder [Serializer] Fix exception thrown by YamlEncoder Dec 29, 2024
@fabpot
Copy link
Member

fabpot commented Jan 6, 2025

Thank you @VincentLanglet.

@fabpot fabpot merged commit d3583b9 into symfony:6.4 Jan 6, 2025
5 of 11 checks passed
This was referenced Jan 29, 2025
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.

4 participants