-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Upgrade to 7.1 - NotNormalizableValueException with $useMessageForUser=true - message lost #57427
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
git bisect seems to indicate d32e81c#diff-29383d2d4706675943994bda3c2e1be15e8008fa4928d4272cf3980454471115 as the first commit to fail |
Can you confirm that #57433 fixes your issue? |
Hi and thank you for your ultra quick fix ! |
Thank YOU very much for providing such a great issue with a reproducer that after all made it possible to fix it that quickly! 👍 |
…ct (HypeMC) This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] Check if exception message in test is correct | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix #57427 (just test) | License | MIT This is a test for #57433 Commits ------- 2fc8789 [Serializer] Check if exception message in test is correct
…ectNormalizer` (HypeMC, xabbuh) This PR was merged into the 7.1 branch. Discussion ---------- [Serializer] forward exceptions caught in the `AbstractObjectNormalizer` | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57427 | License | MIT Commits ------- 6a16b59 forward exceptions caught in the AbstractObjectNormalizer 71d67d4 [Serializer] Check if exception message in test is correct
Symfony version(s) affected
7.1.1
Description
This concerns the denormalisation of a nested object using a custom (de)normalizer and
COLLECT_DENORMALIZATION_ERRORS=true
.In Symfony 6.4 & 7.0, when a custom (de)normalizer throws a
NotNormalizableValueException
with$useMessageForUser = true
in thedenormalize()
function, if Symfony Serializer’s context is set withDenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true
, it throws aPartialDenormalizationException
and usesmessage
,path
, andexpectedTypes
defined inNotNormalizableValueException::createForUnexpectedDataType()
to inform the user.In Symfony 7.1, a broader message is generated using the class of the nested object, and loses the valuable information given by the custom normalizer.
Code in a minimalistic Normalizer
Symfony 6.4 & 7.0 output, with desired message :
Symfony 7.1 output, with a broader message:
How to reproduce
I wrote a simple reproducer, here : https://github.com/yblatti/repro-denorm-error
You'll find relevant code in
src/Controller
,src/DTO
andsrc/Serialization
.The same code is used, only the Symfony version changes accros 3 branches : sf_6.4, sf_7.0, sf_7.1,
To test on different versions :
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: