Skip to content

[HttpKernel] Fix RequestPayloadValueResolver handling error with no ExpectedTypes#52131

Merged
nicolas-grekas merged 1 commit intosymfony:6.3from
Jeroeny:fixnulltype
Jan 30, 2024
Merged

[HttpKernel] Fix RequestPayloadValueResolver handling error with no ExpectedTypes#52131
nicolas-grekas merged 1 commit intosymfony:6.3from
Jeroeny:fixnulltype

Conversation

@Jeroeny
Copy link
Copy Markdown
Contributor

@Jeroeny Jeroeny commented Oct 18, 2023

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
License MIT

The NotNormalizableValueException errors in PartialDenormalizationException->getErrors() have a ->getExpectedTypes() method that returns array|null. The RequestPayloadValueResolver assumes this is always an array.

When the returned value is null, an Exception is thrown with implode(): Argument #1 ($pieces) must be of type array, string given.

Also the exception message in case of an empty array was: This value should be of type ..

#SymfonyHackday

@chalasr
Copy link
Copy Markdown
Member

chalasr commented Jan 29, 2024

Could you please rebase?

@nicolas-grekas
Copy link
Copy Markdown
Member

Thank you @Jeroeny.

@nicolas-grekas nicolas-grekas merged commit 78f82b9 into symfony:6.3 Jan 30, 2024
foreach ($e->getErrors() as $error) {
$parameters = ['{{ type }}' => implode('|', $error->getExpectedTypes())];
$parameters = [];
$template = 'This value was of an unexpected type.';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this message is not in translation maps. Dunno if it matters. Does it?

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.

5 participants