Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Add COLLECT_EXTRA_ATTRIBUTES_ERRORS and full deserialization path#46654

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
NorthBlue333 wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromNorthBlue333:feature/ticket_46283_ticket_46284

Conversation

NorthBlue333
Copy link

@NorthBlue333NorthBlue333 commentedJun 12, 2022
edited
Loading

QA
Branch?6.2
Bug fix?yes/no
New feature?yes
Deprecations?yes
TicketsFix#46283,Fix#46284
LicenseMIT
Doc PRsymfony/symfony-docs#16872

ThePartialDenormalizationException is used as unexpected extra attributes are, IMO, part of the denormalization exception.
This enables executing:

try {$dto =$serializer->deserialize($request->getContent(), MyDto::class,'json', [            DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS =>true,            DenormalizerInterface::COLLECT_EXTRA_ATTRIBUTES_ERRORS =>true,            DenormalizerInterface::ALLOW_EXTRA_ATTRIBUTES =>false,        ]);    }catch (PartialDenormalizationException$e) {$violations =newConstraintViolationList();/** @var NotNormalizableValueException */foreach ($e->getErrors()as$exception) {$message =sprintf('The type must be one of "%s" ("%s" given).',implode(',',$exception->getExpectedTypes()),$exception->getCurrentType());$parameters = [];if ($exception->canUseMessageForUser()) {$parameters['hint'] =$exception->getMessage();            }$violations->add(newConstraintViolation($message,'',$parameters,null,$exception->getPath(),null));        };if (null !==$extraAttributesException =$e->getExtraAttributesError()) {foreach ($extraAttributesException->getExtraAttributes()as$extraAttribute) {$violations->add(newConstraintViolation('This attribute is not allowed.','', [],null,$extraAttribute,null));            };        }return$this->json($violations,400);    }

@NorthBlue333
Copy link
Author

Would ideally need#45861 first.
I can make the necessary changes if needed.

@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch 2 times, most recently frome285d19 to7b8a73aCompareJune 13, 2022 08:23
@NorthBlue333
Copy link
Author

NorthBlue333 commentedJun 13, 2022
edited
Loading

Seems I cannot reproduce the failing tests in local in 8.2? Some help will be appreciated for this :)

@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch 2 times, most recently from3328a3f todac569dCompareJune 13, 2022 11:18
@carsonbot
Copy link

Hey!

I think@mtarld has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch fromdac569d to58fc21eCompareOctober 8, 2022 13:09
@NorthBlue333
Copy link
Author

Any news for this?

@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch from58fc21e toa202da2CompareOctober 8, 2022 13:12
@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch 2 times, most recently fromdaebc6d toadf10e3CompareOctober 8, 2022 13:17
* returned. Otherwise, the concatenation of the two paths is returned,
* separated by a dot (".").
*/
public static function append(string $basePath, string $subPath): string
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update thePropertyPathInterface by adding a new@method phpdoc attribute?

Copy link
Member

Choose a reason for hiding this comment

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

As this is a static method, I don't think it makes sense to add in in the PropertyPathInterface.

NorthBlue333 and mtarld reacted with thumbs up emoji
@NorthBlue333
Copy link
Author

I think I am done with the changes here. 👍

@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch 2 times, most recently fromb01db33 to389804bCompareOctober 10, 2022 17:18
@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch from389804b to536fb94CompareOctober 11, 2022 12:55
@NorthBlue333
Copy link
Author

Done 👍

Copy link
Contributor

@mtarldmtarld left a comment

Choose a reason for hiding this comment

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

LGTM then, thank you@NorthBlue333!

NorthBlue333 reacted with thumbs up emoji
public function getErrors(): array
{
return $this->errors;
return $this->getNotNormalizableValueErrors();

Choose a reason for hiding this comment

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

the method should throw a runtime deprecation
can you remind me why we deprecated the method?
deprecating always comes with a cost so it needs a good enough reason

Copy link
Author

Choose a reason for hiding this comment

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

Well this was because it might be used. Should I completely remove it / throw an exception instead of deprecating it?

@NorthBlue333NorthBlue333force-pushed thefeature/ticket_46283_ticket_46284 branch from536fb94 to2cda4a9CompareOctober 23, 2022 10:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@mtarldmtarldmtarld approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

@chalasrchalasrAwaiting requested review from chalasr

Assignees
No one assigned
Projects
None yet
Milestone
6.4
5 participants
@NorthBlue333@carsonbot@nicolas-grekas@stof@mtarld

[8]ページ先頭

©2009-2025 Movatter.jp