project-mirai / mirai-api-http

Mirai HTTP API (console) plugin
GNU Affero General Public License v3.0
1.66k stars 343 forks source link

http、webhook 获取消息报错 void kotlinx.serialization.PolymorphicSerializer.<init>(kotlin.reflect.KClass, java.lang.annotation.Annotation[] #575

Closed EsunR closed 2 years ago

EsunR commented 2 years ago

使用 http adapter 可以正常获取与绑定 sessionkey,但是调用 fetchMessage 接口时就会收到如下错误响应:

{
    "code": 500,
    "msg": "'void kotlinx.serialization.PolymorphicSerializer.<init>(kotlin.reflect.KClass, java.lang.annotation.Annotation[])'"
}

使用 webhook adapter 时 mcl 启动就会报错,收到消息后也会报错,报错信息如下:

2022-05-15 21:43:49 E/main: Exception in coroutine <unnamed>
java.lang.reflect.InvocationTargetException: 'void kotlinx.serialization.PolymorphicSerializer.<init>(kotlin.reflect.KClass, java.lang.annotation.Annotation[])'
        at kotlinx.serialization.internal.PlatformKt.invokeSerializerOnCompanion(Platform.kt:106)
        at kotlinx.serialization.internal.PlatformKt.constructSerializerForGivenTypeArgs(Platform.kt:41)
        at kotlinx.serialization.internal.PlatformKt.compiledSerializerImpl(Platform.kt:23)
        at kotlinx.serialization.SerializersKt__SerializersKt.serializerOrNull(Serializers.kt:178)
        at kotlinx.serialization.SerializersKt.serializerOrNull(Unknown Source)
        at kotlinx.serialization.SerializersKt__SerializersKt.serializer(Serializers.kt:155)
        at kotlinx.serialization.SerializersKt.serializer(Unknown Source)
        at net.mamoe.mirai.api.http.adapter.internal.serializer.BuiltinJsonSerializer.encode(BuiltinJson.kt:59)
        at net.mamoe.mirai.api.http.adapter.webhook.WebhookAdapter$enable$1.invokeSuspend(WebhookAdapter.kt:86)
        at net.mamoe.mirai.api.http.adapter.webhook.WebhookAdapter$enable$1.invoke(WebhookAdapter.kt)
        at net.mamoe.mirai.api.http.adapter.webhook.WebhookAdapter$enable$1.invoke(WebhookAdapter.kt)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invokeSuspend(EventChannel.kt:455)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invokeSuspend(InternalEventListeners.kt:50)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
        at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
        at net.mamoe.mirai.internal.event.Handler.onEvent(InternalEventListeners.kt:50)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt.process(InternalEventListeners.kt:166)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt.callAndRemoveIfRequired(InternalEventListeners.kt:115)
        at net.mamoe.mirai.event._EventBroadcast.broadcastImpl(Event.kt:174)
        at net.mamoe.mirai.IMirai.broadcastEvent(IMirai.kt:318)
        at net.mamoe.mirai.internal.MiraiImpl.broadcastEvent$suspendImpl(MiraiImpl.kt:308)
        at net.mamoe.mirai.internal.MiraiImpl.broadcastEvent(MiraiImpl.kt)
        at net.mamoe.mirai.event._EventBroadcast.broadcastPublic$suspendImpl(Event.kt:161)
        at net.mamoe.mirai.event._EventBroadcast.broadcastPublic(Event.kt)
        at net.mamoe.mirai.event.EventKt.broadcast(Event.kt:146)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcast$2.invokeSuspend(EventDispatcher.kt:90)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcast$2.invoke(EventDispatcher.kt)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcast$2.invoke(EventDispatcher.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
        at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl.broadcast$suspendImpl(EventDispatcher.kt:89)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl.broadcast(EventDispatcher.kt)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcastAsync$job$1.invokeSuspend(EventDispatcher.kt:105)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcastAsync$job$1.invoke(EventDispatcher.kt)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcastAsync$job$1.invoke(EventDispatcher.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
        at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
        at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl.broadcastAsync-kKe4JaQ(EventDispatcher.kt:102)
        at net.mamoe.mirai.internal.network.components.EventDispatcher.broadcastAsync-kKe4JaQ$default(EventDispatcher.kt:35)
        at net.mamoe.mirai.internal.network.components.EventBroadcasterPacketHandler.impl(PacketHandler.kt:87)
        at net.mamoe.mirai.internal.network.components.EventBroadcasterPacketHandler.impl(PacketHandler.kt:80)
        at net.mamoe.mirai.internal.network.components.EventBroadcasterPacketHandler.handlePacket(PacketHandler.kt:73)
        at net.mamoe.mirai.internal.network.components.PacketHandlerChain.handlePacket(PacketHandler.kt:42)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$collectReceived$3.invokeSuspend(NetworkHandlerSupport.kt:84)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$collectReceived$3.invoke(NetworkHandlerSupport.kt)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$collectReceived$3.invoke(NetworkHandlerSupport.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
        at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
        at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
        at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.collectReceived$mirai_core(NetworkHandlerSupport.kt:82)
        at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$PacketDecodePipeline$send$1.invokeSuspend(NettyNetworkHandler.kt:178)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodError: 'void kotlinx.serialization.PolymorphicSerializer.<init>(kotlin.reflect.KClass, java.lang.annotation.Annotation[])'
        at net.mamoe.mirai.api.http.adapter.internal.dto.EventDTO$Companion$$cachedSerializer$delegate$1.invoke(base.kt:16)
        at net.mamoe.mirai.api.http.adapter.internal.dto.EventDTO$Companion$$cachedSerializer$delegate$1.invoke(base.kt:16)
        at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
        at net.mamoe.mirai.api.http.adapter.internal.dto.EventDTO$Companion.serializer(base.kt:16)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at kotlinx.serialization.internal.PlatformKt.invokeSerializerOnCompanion(Platform.kt:101)
        ... 72 more
ryoii commented 2 years ago

2.5.0 的插件需要使用 2.11 的 core