MrXiaoM/Overflow

使用overflow+Gensokyo尝试获取用户头像出现异常

Closed this issue · 4 comments

问题描述

在使用overflow向Gensokyo发出get_avatar请求后Gensokyo端正常回复,Overflow报出异常

[get_avatar] Cannot invoke "top.mrxiaom.overflow.internal.deps.gson.JsonElement.getAsString()" because the return value of "top.mrxiaom.overflow.internal.deps.gson.JsonObject.get(String)" is null如果你认为这是 Overflow 的问题请带上 logs/onebot 中的日志来反馈

Gensokyo端日志

 get_avatar: map[echo:22 message:https://q.qlogo.cn/qqapp/*** retcode:0 user_id:3.780***]

经测试message提供的链接可以正常访问且内容正确

复现

插件尝试获取头像
String response = bot.executeAction("get_avatar", actionParams);

Overflow 版本

1.0.1

其他组件版本

No response

系统日志

2024-12-20 15:47:45 V/Bot.**: Group(**) <- [mirai:at:**] 
老师请稍等!这就为您抽签!
2024-12-20 15:47:45 W/Onebot: 请求失败: [get_avatar] Cannot invoke "top.mrxiaom.overflow.internal.deps.gson.JsonElement.getAsString()" because the return value of "top.mrxiaom.overflow.internal.deps.gson.JsonObject.get(String)" is null。如果你认为这是 Overflow 的问题,请带上 logs/onebot 中的日志来反馈。
2024-12-20 15:47:45 I/AronaBot: 阿洛娜杂项-{
    "message": "Cannot invoke \"top.mrxiaom.overflow.internal.deps.gson.JsonElement.getAsString()\" because the return value of \"top.mrxiaom.overflow.internal.deps.gson.JsonObject.get(String)\" is null",
    "retcode": -1
}

网络日志

2024-12-20 15:47:45 D/Onebot: [Send] --> {"action":"get_avatar","params":{"user_id":37806****,"group_id":95481****},"echo":42}
2024-12-20 15:47:45 D/Onebot: [Recv] <-- {"echo":42,"message":"https://q.qlogo.cn/qqapp/1*","retcode":0,"user_id":37806****}
2024-12-20 15:47:45 W/Onebot: 请求失败: [get_avatar] Cannot invoke "top.mrxiaom.overflow.internal.deps.gson.JsonElement.getAsString()" because the return value of "top.mrxiaom.overflow.internal.deps.gson.JsonObject.get(String)" is null。如果你认为这是 Overflow 的问题,请带上 logs/onebot 中的日志来反馈。
2024-12-20 15:47:45 V/Onebot: Stacktrace: 
java.lang.NullPointerException: Cannot invoke "top.mrxiaom.overflow.internal.deps.gson.JsonElement.getAsString()" because the return value of "top.mrxiaom.overflow.internal.deps.gson.JsonObject.get(String)" is null
	at cn.evolvefield.onebot.client.util.ActionSendRequest.send(ActionSendRequest.kt:46)
	at cn.evolvefield.onebot.client.util.ActionSendRequest$send$1.invokeSuspend(ActionSendRequest.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178)
	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)
	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328)
	at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1413)
	at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:318)
	at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:295)
	at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:856)
	at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core(JobSupport.kt:806)
	at kotlinx.coroutines.CompletableDeferredImpl.complete(CompletableDeferred.kt:92)
	at cn.evolvefield.onebot.client.util.ActionSendRequest.onCallback(ActionSendRequest.kt:80)
	at cn.evolvefield.onebot.client.handler.ActionHandler.onReceiveActionResp(ActionHandler.kt:41)
	at cn.evolvefield.onebot.client.connection.IAdapter$DefaultImpls.onReceiveMessage(IAdapter.kt:27)
	at cn.evolvefield.onebot.client.connection.WSClient.onReceiveMessage(WSClient.kt:19)
	at cn.evolvefield.onebot.client.connection.WSClient.onMessage(WSClient.kt:68)
	at top.mrxiaom.overflow.internal.deps.websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:661)
	at top.mrxiaom.overflow.internal.deps.websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:986)
	at top.mrxiaom.overflow.internal.deps.websocket.drafts.Draft_6455.processFrame(Draft_6455.java:910)
	at top.mrxiaom.overflow.internal.deps.websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:397)
	at top.mrxiaom.overflow.internal.deps.websocket.WebSocketImpl.decode(WebSocketImpl.java:229)
	at top.mrxiaom.overflow.internal.deps.websocket.client.WebSocketClient.run(WebSocketClient.java:544)
	at java.base/java.lang.Thread.run(Thread.java:840)

补充信息

No response

这说明 Gensokyo 的扩展API不符合onebot标准。

标准的主动 action 返回应该有
status retcode data echo
返回的数据应该放到data里

而你这里返回的却是
echo message retcode user_id

返回的数据全都平铺在根节点了

以 Overflow 的工作逻辑,即使是自定义调用,返回结果也必须要传 status 和 echo,echo 用于回调,status 用于判断是否成功,失败时抛出异常

以 Overflow 的工作逻辑,即使是自定义调用,返回结果也必须要传 status 和 echo,echo 用于回调,status 用于判断是否成功,失败时抛出异常

那能否针对gensokyo的拓展API适配呢?或者有没有其他解决方法

这是不是应该让Gensokyo修改一下:D