Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lukellmann
Copy link
Member

@lukellmann lukellmann commented Mar 5, 2024

When deserializing Events, Event.DeserializationStrategy assumed that the d field was the last field to be observed. If it wasn't the last field, the deserialization could fail in two ways:

  • the t and s fields were ignored if they came after the d field
  • an exception was thrown if the op field came after the d field

To fix these possible failure cases, the deserialization logic has been changed to work in two steps:

  1. decode all fields regardless of order, treating the d field as a plain JsonElement
  2. after all fields have been decoded, construct an Event from the JsonElement, depending on the values of the op, t and s fields

The supertype of Event.DeserializationStrategy has also been changed from DeserializationStrategy<Event?> to DeserializationStrategy<Event> - deserialize no longer returns null in some cases of illegal event payloads, but throws exceptions instead.

Fixes #922

@lukellmann lukellmann requested a review from DRSchlaubi March 12, 2024 05:36
@lukellmann lukellmann marked this pull request as ready for review March 16, 2024 01:43
@lukellmann lukellmann merged commit d1651a7 into main Mar 16, 2024
@lukellmann lukellmann deleted the unknown-d-field-fix branch March 16, 2024 01:55
lukellmann added a commit that referenced this pull request Mar 16, 2024
To keep the diff reasonable, I left this out of #923.
lukellmann added a commit that referenced this pull request Mar 16, 2024
Similar to #923 but for the voice gateway.
lukellmann added a commit that referenced this pull request Mar 16, 2024
Some tests added in #923 seem to time out on Kotlin/JS. To avoid
problems like this in the future, this commit disables test timeouts on
Kotlin/JS completely.
DRSchlaubi pushed a commit that referenced this pull request Mar 16, 2024
Some tests added in #923 seem to time out on Kotlin/JS. To avoid
problems like this in the future, this commit disables test timeouts on
Kotlin/JS completely.
DRSchlaubi pushed a commit that referenced this pull request Mar 16, 2024
To keep the diff reasonable, I left this out of #923.
DRSchlaubi pushed a commit that referenced this pull request Mar 19, 2024
* Rewrite VoiceEvent.DeserializationStrategy

Similar to #923 but for the voice gateway.

* Log and ignore all unexpected opcodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERROR dev.kord.gateway.DefaultGateway

2 participants