fix(runtime): surface clean business message from failed action, not the sandbox debug wrapper#2534
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…the sandbox debug wrapper A user throw inside a script/action body is wrapped by the sandbox as `<kind> '<name>' threw: <msg>` for server logs, but the action HTTP endpoint returned that whole wrapper as the client-facing `error`, so an action's error toast leaked the debug prefix (e.g. "action 'lead_apply_convert' threw: Error: ...") to end users. SandboxError now also carries `innerMessage` — the plain business message (no wrapper, no default `Error: ` name prefix). The action route surfaces that to the client and keeps the full wrapper in the server log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
某项目动作
lead_apply_convert校验失败时,用户看到的错误 toast 是:前面
action '<name>' threw: Error:这段是框架给日志/开发看的调试包装,不该展示给终端用户。根因
用户在 script/action body 里
throw new Error('线索信息不完整…'),沙箱把它包成<kind> '<name>' threw: <msg>(SandboxError.message,用于服务端日志),而动作 HTTP 端点在 catch 里把整个包装串原样当作 client 端error返回(http-dispatcher.ts的handleActionscatch),于是调试前缀泄漏到了前端 toast。改动
SandboxError新增innerMessage字段:去掉<kind> '<name>' threw:包装、并剥掉默认的Error:名字前缀后的纯业务消息。仅「用户代码抛出」的 4 个threw:站点填它;沙箱自身的内部错误(能力拒绝/超时/marshal)不填,保持原样。TypeError:/RangeError:等)作为「这是真 bug 而非业务规则」的线索。innerMessage回给 client;完整包装串仍打进服务端日志便于排查。用户现在只会看到「线索信息不完整,提交转商机申请前请补全:终端客户」。
测试
packages/runtime全部单测通过(24/24),新增SandboxError.innerMessage断言(.message留包装、.innerMessage为纯业务原文)。@objectstack/runtimeturbo build(含 DTS 类型构建)通过。