DenormalizationViolationFactory crash when GroupSequence is used
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 64/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend-api-design
Línea de trabajo
Start with src/Validator/DenormalizationViolationFactory.php around collectConstraints() and the reported call at line 130; compare how src/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactory.php handles GroupSequence. Reproduce with the provided PATCH test and GroupSequence; done when validation returns the expected 400 response without the type error and the relevant tests pass.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
API Platform version(s) affected: 5.0.2
Description
I have a patch operation
new Patch(
denormalizationContext: ['groups' => ['update:slug-target']],
security: "is_granted('slug_target.update', object)",
validationContext: [
'groups' => new Assert\GroupSequence(['Requirements', ['SlugTarget', 'update:slug-target']]),
],
),
which was working fine on 4.3. As soon as I bump on 5.0 I get an error in one of my tests
An error occurred","detail":"ApiPlatform\\Validator\\DenormalizationViolationFactory::collectConstraints(): Argument #3 ($validationGroups) must be of type ?array, Symfony\\Component\\Validator\\Constraints\\GroupSequence given, called in \/app\/vendor\/api-platform\/validator\/DenormalizationViolationFactory.php on line 130
My test was
$client->request('PATCH', '/slug-targets/'.$uuid, [
'json' => ['quality' => null],
'headers' => ['Content-Type' => 'application/merge-patch+json'],
]);
static::assertResponseStatusCodeSame(400);
The purpose was to test the constraint
#[Assert\Choice(choices: [TranslationQuality::REVIEWED], message: 'slug_target.quality.choices', groups: ['update:slug-target'])]
applied on the quality field.
Possible Solution
It's clear that GroupSequence are not handled here @soyuka
https://github.com/api-platform/core/blob/6f77a4d70fea96bdc1c259749cecfdeb135e9704/src/Validator/DenormalizationViolationFactory.php#L129-L130
I'm not sure about the purpose of the DenormalizationViolationFactory class/method but maybe there is something to copy from the ValidatorPropertyMetadataFactory.
https://github.com/api-platform/core/blob/6f77a4d70fea96bdc1c259749cecfdeb135e9704/src/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactory.php#L155-L197
- Lenguaje dominante
- PHP
- Estrellas
- 2.6k
- Forks
- 989
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 87
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de api-platform/core
-
SkolemIriConverter isn't reset between requests in worker mode (missing kernel.reset tag)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
api-platform/core#8680 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
api-platform/core#8664 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Metadata] Incorrect api schema for path variablePosiblemente ocupada @bram123 la tomó hace 2 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
api-platform/core#8646 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
HTTP cache purgers error handling and performance issuesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
api-platform/core#8591 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
api-platform/core#8535 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de api-platform/core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Automattic/blocks-engine#2803 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hestiacp/hestiacp#5798 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
wp-media/imagify-plugin#1289 ·
Los mantenedores suelen responder en 5 días
-
Sidebar highlights two items when plugin routes share a prefix (/plugin/foo and /plugin/foo-bar)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
getgrav/grav-plugin-admin2#195 ·