Skip to content
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

Bug: empty string serde and Kotlin in 2.8.2 #794

Open
wants to merge 1 commit into
base: 2.9.x
Choose a base branch
from

Conversation

timyates
Copy link
Contributor

@timyates timyates commented Mar 18, 2024

I believe there is an issue in 2.8.2 when serializing an empty string to a non-null field in Kotlin, which is reproduced by this PR.

Instead of the expected validation error fruitCommand.name: must not be empty, with Kotlin we get:

Parameter specified as non-null is null: method example.FruitCommand.<init>, parameter name

This works in 2.8.1, and was exposed by the eclipsestore guide https://github.com/micronaut-projects/micronaut-guides/pull/1443\#commits-pushed-0276ab1

There is an issue in 2.8.2 when serializing an empty string to a non-null field in Kotlin.

This works in 2.8.1, and was exposed by the eclipsestore guide https://github.com/micronaut-projects/micronaut-guides/pull/1443\#commits-pushed-0276ab1
@timyates timyates added type: bug Something isn't working lang: kotlin Issues or features specific to Kotlin labels Mar 18, 2024
@timyates timyates added this to the 2.8.3 milestone Mar 18, 2024
@timyates timyates assigned timyates and dstepanov and unassigned timyates Mar 18, 2024
@timyates
Copy link
Contributor Author

Actually, I'm not sure if this reproducer is correct...

Going back to earlier commits, the Kotlin tests in this PR still seem to fail, and I'm not sure why...

However in the EclipseStore guide (check out micronaut-guides, and run ./gradlew mEPBuild), adding

configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == "io.micronaut.serde") {
            details.useVersion("2.8.1")
        }
    }
}

To the build of the kotlin guide does make it pass...

timyates added a commit to micronaut-projects/micronaut-guides that referenced this pull request Mar 18, 2024
sdelamo pushed a commit to micronaut-projects/micronaut-guides that referenced this pull request Mar 18, 2024
@dstepanov
Copy link
Contributor

It looks correct to me; the default inclusion setting is NON_EMPTY. So, an empty string is omitted.
For Java we can initialize beans even with non-null but not for Kotlin.

@timyates
Copy link
Contributor Author

@dstepanov did something change to make the old way invalid? As far as I can see, this used to work

@dstepanov
Copy link
Contributor

Not sure, maybe the configuration of the inclusion wasn't properly delegated?

@dstepanov
Copy link
Contributor

I think there was additional String Serde that didn't had implemented isEmpty method 6489c8e#diff-56e4febbd38eabfee4eb5f5829aa0e2a3b0a9af1d7be8dcb75bb6dd8673b9ae4L183

AndreaLaGrotteria pushed a commit to AndreaLaGrotteria/micronaut-guides that referenced this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: kotlin Issues or features specific to Kotlin type: bug Something isn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants