Open
Description
Given that I make any request that tries to decode something to a List<T>
, where T
is not serializable, Ktor-client will generate an error like this:
kotlinx.serialization.SerializationException: Serializer for class 'List' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
at kotlinx.serialization.internal.Platform_commonKt.serializerNotRegistered(Platform.common.kt:90)
at kotlinx.serialization.SerializersKt__SerializersKt.serializer(Serializers.kt:299)
at kotlinx.serialization.SerializersKt.serializer(Unknown Source)
at io.ktor.serialization.kotlinx.SerializerLookupKt.serializerForTypeInfo(SerializerLookup.kt:32)
at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:66)
at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:51)
Adding @Serializable
to T
fixed this in my case.
It's very frustrating and throws the user in the wrong direction. It seems to apply to all boxed types. For instance
data class Foo(val bar: Int)
@Serializable
data class Box<out T>(val value: T)
fun main() {
client.get("").body<Box<Foo>>()
}
Will generate a similar error statingkotlinx.serialization.SerializationException: Serializer for class 'Box' is not found.
Once again, making Foo serializable would fix this
Ktor version: 3.1.0
KxS version: 1.8.0
Kotlin version: 2.1.0
Metadata
Metadata
Assignees
Labels
No labels