Skip to content

feat(Serializer): update MissingConstructorArgumentsException message #5902

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ERuban
Copy link
Contributor

@ERuban ERuban commented Oct 19, 2023

Q A
Branch? main
License MIT

Accidentally have closed #5649 PR
This is its copy.

Have found that if validation attributes are specified on DTOs or if the Valid() constraint is used on not api-resource property (just an entity in example) then Symfony's AbstractNormalizer is used and it has a bit different MissingConstructorArgumentsException exception message that also contains the list of missed arguments.
But in ApiPlatform this exception has another message and it contains only the first one of missed arguments in it.
This way someone, who relies on this message, in example, to convert it to something like validation error in the response, will get different messages.
So I want to suggest to make this message and its parameters consistent with Symfony's one.

The example of the new message:

Cannot create an instance of "App\Entity\Book" from serialized data because its constructor requires the following parameters to be present : "$author", "$name".

@ERuban ERuban changed the title feature-make-MissingConstructorArgumentsException-message-consistent-… feat(Serializer): update MissingConstructorArgumentsException message Oct 19, 2023
@ERuban ERuban force-pushed the feature-make-MissingConstructorArgumentsException-message-consistent-with-symfony-one branch from ce70fb6 to 273c13e Compare October 19, 2023 10:22
@soyuka soyuka requested a review from dunglas October 19, 2023 12:26
Copy link

stale bot commented Dec 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 18, 2023
@ERuban
Copy link
Contributor Author

ERuban commented Dec 18, 2023

@dunglas 👋

@stale stale bot removed the stale label Dec 18, 2023
Copy link

stale bot commented Feb 16, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 16, 2024
@ERuban
Copy link
Contributor Author

ERuban commented Feb 16, 2024

up

@stale stale bot removed the stale label Feb 16, 2024
Copy link

stale bot commented Apr 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 17, 2024
@soyuka soyuka merged commit 57fe136 into api-platform:main Apr 21, 2024
@soyuka
Copy link
Member

soyuka commented Apr 21, 2024

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants