We've tried to block and unblock bot and the logs of bot went crazy, there was one constant unstoppable error:
kotlinx.serialization.json.internal.JsonDecodingException: Polymorphic serializer was not found for missing class discriminator ('null')
JSON input: {"user":{"id":12...5,"is_bot":true,"first_name":"name","username":"username"},"status":"member"}
It reduced to the following code failing with the sam issue:
val json = "{\"user\":{\"id\":120,\"is_bot\":true,\"first_name\":\"name\",\"username\":\"username\"},\"status\":\"member\"}"
println(Json.decodeFromString<ChatMember>(json))
So the problem was that there was no information that can be used to determine which subclass of ChatMember to use in deserialization. This information contains in field status (in documentation: ChatMemberOwner, status - The member's status in the chat, always "creator"; and other "always" values for each type).
We've tried to block and unblock bot and the logs of bot went crazy, there was one constant unstoppable error:
It reduced to the following code failing with the sam issue:
So the problem was that there was no information that can be used to determine which subclass of
ChatMember
to use in deserialization. This information contains in fieldstatus
(in documentation:ChatMemberOwner
, status - The member's status in the chat, always "creator"; and other "always" values for each type).Now the above kotlin code runs successfully.