Exception in thread "main" java.lang.IllegalArgumentException: Value for serializer ContextDescriptor(kClass: class java.lang.Object (Kotlin reflection is not available), original: kotlinx.serialization.Polymorphic(type: kotlin.String, value: kotlinx.serialization.Polymorphic<Any>)) should always be non-null. Please report issue to the kotlinx.serialization tracker.
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue (StreamingJsonEncoder.kt:249)
at kotlinx.serialization.encoding.AbstractEncoder.encodeSerializableElement (AbstractEncoder.kt:80)
at Response$OK.write$Self$web_module (File.kt:7)
Describe the bug
The following code fails in runtime with:
To Reproduce
Playground: https://pl.kotl.in/SHyoGHTDb.
Expected behavior
It's serialized successfully either to
{type: ok, data: null}
or{type: ok}
.Environment