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

Properly decode null in gateway events #286

Merged
merged 2 commits into from
May 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gateway/src/main/kotlin/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import dev.kord.common.entity.optional.OptionalSnowflake
import kotlinx.serialization.*
import kotlinx.serialization.builtins.nullable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
Expand All @@ -31,7 +28,10 @@ private object NullDecoder : DeserializationStrategy<Nothing?> {

@OptIn(ExperimentalSerializationApi::class)
override fun deserialize(decoder: Decoder): Nothing? {
return decoder.decodeNull()
// decodeNull() doesn't consume the literal null therefore parsing doesn't end and in e.g. a heartbeat event
// the null gets parsed as a key
decoder.decodeNotNullMark()
return null
DRSchlaubi marked this conversation as resolved.
Show resolved Hide resolved
}

}
Expand Down