You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect the SerdeException (or one of it's subclasses, InvalidFormatException, etc) to contain some context about the location of an error it encounters while trying to deserialize.
Jackson provides a getPath() method in it's JsonMappingException which is the super of things like InvalidFormatException and InvalidPropertyException, this allows one access to the json path in question.
micronaut-serialization should provide similar functionality.
At the moment it's not possible to write an ExceptionHandler to handle these situation and return a custom error message with the details.
Incorrect generic exception thrown
Invalid enum values
A SerdeException is thrown instead of it's subclass InvalidFormatException,
Minified stacktrace:
io.micronaut.core.convert.exceptions.ConversionErrorException: Failed to convert argument [test] for value [null] due to: Error decoding property [TestEnum enum] of type [class mktplc.error.JacksonExceptionHandlerTest$Test]: No enum constant mktplc.error.JacksonExceptionHandlerTest.TestEnum.invalid
....
Caused by: io.micronaut.serde.exceptions.SerdeException: Error decoding property [TestEnum enum] of type [class mktplc.error.JacksonExceptionHandlerTest$Test]: No enum constant mktplc.error.JacksonExceptionHandlerTest.TestEnum.invalid
....
Caused by: java.lang.IllegalArgumentException: No enum constant mktplc.error.JacksonExceptionHandlerTest.TestEnum.invalid
If InvalidFormatException was thrown we would at least have access to it's originalValue.
Unknown property (when ignore-unknown is set to false)
When an unknown property is encountered Jackson has an IgnoredPropertyException to represent this, along with appropriate context about the field/property in question.
micronaut-serialization should provide similar functionality.
Minified stacktrace:
io.micronaut.core.convert.exceptions.ConversionErrorException: Failed to convert argument [test] for value [null] due to: Unknown property [unknown] encountered during deserialization of type: Test test
...
Caused by: io.micronaut.serde.exceptions.SerdeException: Unknown property [unknown] encountered during deserialization of type: Test test
Actual Behaviour
See Expected Behavior
Steps To Reproduce
@Controller("/test")
classTestController {
@Post
@Consumes(MediaType.APPLICATION_JSON)
funjackson(@Body test:Test) {
// no-opLOG.info { "Request Body: $test" }
}
}
@Serdeable
classTest {
var string:String?=nullvar enum:TestEnum?=null
}
@Serdeable
enumclassTestEnum { A, B, C }
// apologies for this not being immediately compileable // invalid enum valueval ignore:HttpResponse<Void> = httpClient.toBlocking()
.exchange(
HttpRequest.POST(embeddedServer.uri.toASCIIString() +"/test", "{\"enum\":\"invalid\"}")
.contentType(MediaType.APPLICATION_JSON_TYPE)
)
// unknown property val ignore:HttpResponse<Void> = httpClient.toBlocking()
.exchange(
HttpRequest.POST(embeddedServer.uri.toASCIIString() +"/test", "{\"unknown\":\"invalid\"}")
.contentType(MediaType.APPLICATION_JSON_TYPE)
)
Environment Information
MacOs
JDK 17
Micronaut Platform 4.1.5
Example Application
No response
Version
Micronaut Platform 4.1.5
The text was updated successfully, but these errors were encountered:
Expected Behavior
I expect the
SerdeException
(or one of it's subclasses,InvalidFormatException
, etc) to contain some context about the location of an error it encounters while trying to deserialize.Jackson provides a
getPath()
method in it'sJsonMappingException
which is the super of things likeInvalidFormatException
andInvalidPropertyException
, this allows one access to the json path in question.micronaut-serialization should provide similar functionality.
At the moment it's not possible to write an
ExceptionHandler
to handle these situation and return a custom error message with the details.Invalid enum values
A
SerdeException
is thrown instead of it's subclassInvalidFormatException
,Minified stacktrace:
If
InvalidFormatException
was thrown we would at least have access to it'soriginalValue
.Unknown property (when
ignore-unknown
is set tofalse
)When an unknown property is encountered Jackson has an
IgnoredPropertyException
to represent this, along with appropriate context about the field/property in question.micronaut-serialization should provide similar functionality.
Minified stacktrace:
Actual Behaviour
See Expected Behavior
Steps To Reproduce
Environment Information
MacOs
JDK 17
Micronaut Platform 4.1.5
Example Application
No response
Version
Micronaut Platform 4.1.5
The text was updated successfully, but these errors were encountered: