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

NoTransformationFoundException - expected kotlin.Boolean but found kotlin.Boolean #744

Open
padmalcom opened this issue Nov 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@padmalcom
Copy link

padmalcom commented Nov 23, 2024

Ktorfit version

2.2.0

What happened and how can we reproduce this issue?

Hi I have this simple REST endpoint in my backend application:

@GetMapping("/api/v1/user/existsByEmail/{email}")
fun userExistsByEmail(@PathVariable("email") email: String) : ResponseEntity<Boolean> {
    return ResponseEntity.ok().body(userService.emailExists(email))
}

My ktorfit client look like that:

@GET(Endpoints.USER_EMAIL_EXISTS)
suspend fun userExistsByEmail(
    @Path("email") email: String
): Response<Boolean>

When calling the endpoint from the client I get a strange error message which is:

io.ktor.client.call.NoTransformationFoundException: Expected response body of the type 'class kotlin.Boolean' but was 'class kotlin.Boolean'
In response from http://10.0.2.2:8080/api/v1/user/existsByEmail/[email protected]
Response status 200
Response header ContentType: application/json
Request header Accept: application/json

What did you expect to happen?

I'd expect ktorfit to parse the result as boolean wrapped as response successfully.

Is there anything else we need to know about?

Additional finding: When I remove the Response wrapper arount the Boolean, the endpoint works fine.

I already posted a KTOR issue but the devs could not reproduce it and mentioned to file a bug here because it might be ktorfit related: https://youtrack.jetbrains.com/issue/KTOR-7835/NoTransformationFoundException-expected-kotlin.Boolean-but-found-kotlin.Boolean

@padmalcom padmalcom added the bug Something isn't working label Nov 23, 2024
@padmalcom
Copy link
Author

padmalcom commented Nov 25, 2024

Found out today: When I remove the Response wrapper arount the Boolean, the endpoint works fine.
Interesting is: If there is a complex object wrapped in the Response, the API works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant