kordlib / kord

Idiomatic Kotlin Wrapper for The Discord API
MIT License
926 stars 82 forks source link

Exception #911

Closed Rattlyy closed 9 months ago

Rattlyy commented 9 months ago

Don't really know which event fires this.

[DefaultDispatcher-worker-5] ERROR dev.kord.gateway.DefaultGateway - 
kotlinx.serialization.json.internal.JsonDecodingException: String literal for key 'primitive' should be quoted.
Use 'isLenient = true' in 'Json {}' builder to accept non-compliant JSON.
JSON input: 1024
        at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
        at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
        at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeTaggedString(TreeJsonDecoder.kt:144)
        at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeTaggedString(TreeJsonDecoder.kt:36)
        at kotlinx.serialization.internal.TaggedDecoder.decodeString(Tagged.kt:231)
        at dev.kord.common.DiscordBitSet$Serializer.deserialize(DiscordBitSet.kt:119)
        at dev.kord.common.DiscordBitSet$Serializer.deserialize(DiscordBitSet.kt:116)
        at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:61)
        at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:52)
        at dev.kord.common.entity.Permissions$Serializer.deserialize(Permission.kt:733)
        at dev.kord.common.entity.Permissions$Serializer.deserialize(Permission.kt:721)
        at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:61)
        at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:52)
        at kotlinx.serialization.json.internal.TreeJsonDecoderKt.readJson(TreeJsonDecoder.kt:25)
        at kotlinx.serialization.json.Json.decodeFromJsonElement(Json.kt:127)
        at dev.kord.common.entity.AuditLogChange$Serializer.deserialize(AuditLog.kt:214)
        at dev.kord.common.entity.AuditLogChange$Serializer.deserialize(AuditLog.kt:189)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
        at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
        at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
        at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)
        at kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)
        at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
        at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
        at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
        at dev.kord.common.entity.optional.Optional$OptionalSerializer.deserialize(Optional.kt:177)
        at dev.kord.common.entity.optional.Optional$OptionalSerializer.deserialize(Optional.kt:155)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
        at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
        at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
        at dev.kord.common.entity.DiscordAuditLogEntry$$serializer.deserialize(AuditLog.kt:105)
        at dev.kord.common.entity.DiscordAuditLogEntry$$serializer.deserialize(AuditLog.kt:105)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
        at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
        at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
        at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)
        at dev.kord.gateway.Event$DeserializationStrategy.getByDispatchEvent(Event.kt:175)
        at dev.kord.gateway.Event$DeserializationStrategy.deserialize(Event.kt:67)
        at dev.kord.gateway.Event$DeserializationStrategy.deserialize(Event.kt:35)
        at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
        at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
        at dev.kord.gateway.DefaultGateway.read(DefaultGateway.kt:189)
        at dev.kord.gateway.DefaultGateway.access$read(DefaultGateway.kt:62)
        at dev.kord.gateway.DefaultGateway$readSocket$2.emit(DefaultGateway.kt:173)
        at dev.kord.gateway.DefaultGateway$readSocket$2.emit(DefaultGateway.kt:171)
        at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:37)
        at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(Channels.kt:1)
        at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Channels.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
lukellmann commented 9 months ago

It is probably this: https://github.com/discord/discord-api-docs/issues/6616 Also see this conversation in the Kord Discord server.

I think I know how to fix this, will try do it later today.

Rattlyy commented 9 months ago

Okay. I managed to reproduce it while editing a channel's permissions, so it does make sense.

lukellmann commented 9 months ago

Okay. I managed to reproduce it while editing a channel's permissions, so it does make sense.

Makes sense, that will trigger an audit log entry create event that contains the JSON Kord can't parse right now.

lukellmann commented 9 months ago

When the build for #912 succeeds you can try out bit-set-fixes-SNAPSHOT to test if this fixes your issue.

lukellmann commented 9 months ago

When the build for #912 succeeds you can try out bit-set-fixes-SNAPSHOT to test if this fixes your issue.

also @Tmpod

lukellmann commented 9 months ago

The fix is merged and will be included in the next release. If needed I could also do a 0.13.1 release just containing this fix - let me know.

Tmpod commented 9 months ago

I completely missed your ping a couple of days ago, sorry!
Thanks for the fix, will try it soon (maybe tomorrow).