[Bug] CAPTCHA SDK reject 普通对象时错误信息被 `String(t)` 转成 `[object Object]`
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复 / I searched existing issues and confirmed this isn't a duplicate.
- 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category
稳定性 / 崩溃 · Stability / Crash
涉及的 Agent 框架 · Agent framework
ZCode Agent(自研)
严重程度 · Severity
阻塞使用 · Blocking (无法使用核心功能 / core function unusable)
复现频率 · Reproducibility
必现 · Always
问题描述 · Description
排查 Start Plan CAPTCHA 问题时发现,renderer 在处理 Aliyun CAPTCHA SDK 异常时,会把非 Error 类型直接通过 String(t) 转成字符串。
但 Aliyun SDK 的部分失败路径 reject 的是普通 object。
因此原本包含错误码和错误消息的对象最终会变成:
[object Object]
用户界面最后只能看到类似:
Turn execution failed
provider=builtin:bigmodel-start-plan
model=GLM-5.3-Flash
reason=unknown
retryable=false
[object Object]
除了用户看不到真实错误,后续依赖错误 code / message 做分类的逻辑也无法正确识别这类异常。
代码位置
Windows v3.11.2 app.asar renderer bundle,偏移约 272855740:
catch (t) {
n = t instanceof Error ? t.message : String(t);
J.warn(
`[captcha] provider runtime headers refresh failed`,
{
providerId: e.request.providerId,
requestId: e.request.requestId,
error: n
}
);
}
Aliyun SDK 的部分 onFail 路径返回的是类似:
{
code: "INIT_FAIL",
msg: "Error: network error"
}
这种普通 object。
JavaScript:
String({
code: "INIT_FAIL",
msg: "Error: network error"
})
结果只能得到:
[object Object]
本地验证
为了确认这里是不是信息丢失点,我在本地对这一处做了一个仅用于诊断的等长 patch,把普通 object 的处理临时改成 JSON 序列化。
补丁前两次同类失败:
[object Object]
补丁后,同一失败路径得到:
{"code":"INIT_FAIL","msg":"Error: network error"}
随后可以继续定位到 Aliyun SDK 的 XHR onerror / INIT_FAIL 路径。
所以这里的信息丢失可以稳定解释。
复现步骤 · Steps to reproduce
- 使用 Start Plan。
- 让 Aliyun CAPTCHA SDK 的初始化或设备风控请求进入
onFail。 - SDK reject 一个普通 object,而不是
Error。 - renderer catch 到异常。
- runtime / UI 最终只能收到:
[object Object]
期望表现 · Expected behavior
至少应该保留 SDK 原始的:
code
msg
message
verifyCode
等可诊断信息,而不是把整个 object 压成 [object Object]。
实际表现 · Actual behavior
可能可以考虑的处理方式
最简单可以兼容普通 object:
n = t instanceof Error
? t.message
: (t && typeof t === "object")
? (t.msg || t.message || JSON.stringify(t))
: String(t);
如果协议允许,更理想的方式可能是不要在 renderer 这一层过早把 SDK error 压成字符串,而是保留结构化字段,例如:
errorCode
errorMessage
verifyCode
certifyId
这样下游可以直接区分不同的 SDK / CAPTCHA failure,而不需要再从字符串中做关键词匹配。
ZCode 版本 · ZCode version
ZCode Desktop v3.11.2
设备 / 系统 / 浏览器 · Device / OS / Browser
- Windows 11 24H2 -
app.asar: 281,013,156 bytes - Start Plan / GLM-5.3-Flash
截图 / 录屏 / 日志 · Screenshots / Recordings / Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the renderer catch block shown in the issue and locate its source counterpart rather than editing the compiled app.asar bundle. Reproduce the Aliyun CAPTCHA onFail path, then verify that ordinary-object rejections preserve the reported diagnostic fields instead of becoming [object Object].
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100