-
Notifications
You must be signed in to change notification settings - Fork 18
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
JsonSyntaxException is not thrown when provided an invalid JSON #941
Comments
@yawkat can you have a look at this one |
If you want the old behavior you can switch to micronaut-jackson-databind. We switched the default serialization framework in 4.0. |
@yawkat I'm not sure how this applies, the previous version was already on |
@yawkat why is there a difference in behaviour between Jackson and Micronaut Serialization here since the exception is |
Ahh I thought this was an upgrade from 3.6.2, given the version at the bottom. I'll take another look. |
My bad, sorry about the discrepancy! |
Expected Behavior
Previously was running on Micronaut 4.4.2 and when an invalid JSON payload such as below is provided, Micronaut would throw
io.micronaut.json.JsonSyntaxException
and we could handle this with a global exception handler.Actual Behaviour
On Micronaut 4.6.2, instead
io.micronaut.core.convert.exceptions.ConversionErrorException
is being thrown.Steps To Reproduce
./gradlew run
You will have seen that the global exception handler in
DemoController
will kick in and handle ConversionException which controller will respond with messageConversionException is thrown
4. Edit
gradle.properties
and change 1st line to downgrade to Micronaut version to4.4.2
micronautVersion=4.4.2
and save5. Repeat steps 2 and 3 to run the service with the older version of Micronaut
6. You will have seen that the output is different
JsonSyntaxException is thrown
Environment Information
macOS Sonoma 14.7 BuildVersion: 23H124
Gradle 8.8
Kotlin: 1.9.22
Groovy: 3.0.21
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.12 (Amazon.com Inc. 17.0.12+7-LTS)
OS: Mac OS X 14.7 aarch64
Example Application
https://github.com/salih/micronaut-bug-october-24/
Version
4.6.2
The text was updated successfully, but these errors were encountered: