Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

DenormalizationViolationFactory crash when GroupSequence is used

Đã đóng
#8,639 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
64/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, symfony
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
PHP
Star
2.6k
Fork
989
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
90

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/core

Tất cả issue của api-platform/core

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.