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've discovered that for POST body params, kotlin default values are silently ignored and are set to "zero" values instead. Adding validation doesn't help, and adding required parameters doesn't help either. This is a very serious issue because programmers assume that core language functionality actually works like it's supposed to, and this can lead to a lot of tricky bugs.
This is serious enough that Micronaut can't honestly say it supports Kotlin if this doesn't work. Data classes are a big selling point of Kotlin, and if Micronaut can't use them correctly, then I don't think it's fair to say that kotlin is supported. I've done some googling and it looks like this may be caused by changes in some of micronaut's dependencies. However, that doesn't matter. At the end of the day, if you guys say you support a language, then the framework needs to work correctly in that language. Or, you need big warnings documenting that some core language features don't work at all, or worse, only work for certain cases.
Is there any way to make kotlin defaults work with serialization?
// Hit the endpoint with POST /temp {"required": "some value"}
@Controller
openclassMyController {
privatevalLOG=LoggerFactory.getLogger(this::class.java)
@Serdeable
data classParams(
valrequired:String,
// WorksvalstringDefault:String = "default",
// Silently ignoredvalboolDefault:Boolean = true,
// Silently ignoredvallongDefault:Long = 5,
)
@Post("/temp")
@Secured(REST_OPS_WEB_DEV_TEAM)
opensuspendfuntemp(
@Body params:Params,
) {
LOG.info("params: $params")
}
}
Actual Behaviour
Default values are silently ignored.
Environment Information
No response
Example Application
No response
Version
4.7.4
The text was updated successfully, but these errors were encountered:
Expected Behavior
I've discovered that for POST body params, kotlin default values are silently ignored and are set to "zero" values instead. Adding validation doesn't help, and adding required parameters doesn't help either. This is a very serious issue because programmers assume that core language functionality actually works like it's supposed to, and this can lead to a lot of tricky bugs.
This is serious enough that Micronaut can't honestly say it supports Kotlin if this doesn't work. Data classes are a big selling point of Kotlin, and if Micronaut can't use them correctly, then I don't think it's fair to say that kotlin is supported. I've done some googling and it looks like this may be caused by changes in some of micronaut's dependencies. However, that doesn't matter. At the end of the day, if you guys say you support a language, then the framework needs to work correctly in that language. Or, you need big warnings documenting that some core language features don't work at all, or worse, only work for certain cases.
Is there any way to make kotlin defaults work with serialization?
Actual Behaviour
Default values are silently ignored.
Environment Information
No response
Example Application
No response
Version
4.7.4
The text was updated successfully, but these errors were encountered: