-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
#[MapRequestPayload] does not work if a DTO contains **only** nested DTOs #50708
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
Comments
The problem is that you haven't excluded your DTOs from being automatically loaded by the container. You can either add an |
unreferenced services that are broken due autodiscovery should not be an issue, but im afraid |
I think argument with this attribute should not be considered by DI as a service. |
A reference is created by the Adding Excluding the DTOs from the container would indeed work, but it feels like the compilation should not fail anyways 🤔 |
The hints shared in this discussion are good ones, but I didn't manage to reproduce the issue by just creating the 3 classes in the description. |
https://github.com/someniatko/symfony-50708-reproducer UPD: I've excluded irrelevant bundles from the reproducer |
Thank you! |
Symfony version(s) affected
6.3.0+
Description
If you use
#MapRequestPayload
attribute on a DTO whose only field is a nested DTO, Symfony crashes on the container compilation stage.How to reproduce
(Also see https://github.com/someniatko/symfony-50708-reproducer)
Consider a following situation:
Then execute
php bin/console cache:clear
for any environment.Expected: Cache clears successfully
Actual:
It took me almost four hours to pinpoint the issue, because I thought maybe some of the bundles I use are the culprit, or my config is incorrect, and also because, and it's the most "funny" part, this will work fine:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: