You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating symfony/serializer we encountered issues when using #[MapQueryString] with an object containing a parameter-annotation list` and a validator chain.
How to reproduce
#[Route('test',methods: 'GET', format: 'json')]
class MyController
{
publicfunction__invoke(
#[MapQueryString()]
QueryString$queryString = newQueryString()
) {}
}
class QueryString
{
/** * @param list<positive-int> $ids */publicfunction__construct(
#[Assert\All(constraints: [
newAssert\NotBlank(message: 'Invalid id: value must not be empty'),
newAssert\Regex('|^[1-9][0-9]*$|', message: 'Invalid id: value must be a positive integer'),
])]
public ?array$ids = null,
) {}
}
When calling /test?ids[]= or /test?ids[]=foo with symfony/serializer:8.1.4 we got the error message Invalid id: value must not be empty resp. Invalid id: value must be a positive integer, With symfony/serializer:8.1.5 we get This value should be of type int.
The validator-chain is never triggered.
Possible Solution
Replacing the list<positive-int> with list<mixed> solves the issue - with the drawback of being the wrong type.
Staying on symfony/validator:8.1.4 will not be feasible
Symfony version(s) affected
8.1.5
Description
After updating symfony/serializer we encountered issues when using
#[MapQueryString] with an object containing a parameter-annotationlist` and a validator chain.How to reproduce
When calling
/test?ids[]=or/test?ids[]=foowith symfony/serializer:8.1.4 we got the error messageInvalid id: value must not be emptyresp.Invalid id: value must be a positive integer, With symfony/serializer:8.1.5 we getThis value should be of type int.The validator-chain is never triggered.
Possible Solution
list<positive-int>withlist<mixed>solves the issue - with the drawback of being the wrong type.Additional Context
This seems to have been introduced in symfony/serializer@c1c0a96 - commited by @nicolas-grekas and co-authored by @SamuilovAD