Skip to content

fix(runtime): surface clean business message from failed action, not the sandbox debug wrapper#2534

Merged
baozhoutao merged 2 commits into
mainfrom
claude/sad-bun-cb465e
Jul 3, 2026
Merged

fix(runtime): surface clean business message from failed action, not the sandbox debug wrapper#2534
baozhoutao merged 2 commits into
mainfrom
claude/sad-bun-cb465e

Conversation

@baozhoutao

@baozhoutao baozhoutao commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

问题

某项目动作 lead_apply_convert 校验失败时,用户看到的错误 toast 是:

action 'lead_apply_convert' threw: Error: 线索信息不完整,提交转商机申请前请补全:终端客户

前面 action '<name>' threw: Error: 这段是框架给日志/开发看的调试包装,不该展示给终端用户。

根因

用户在 script/action body 里 throw new Error('线索信息不完整…'),沙箱把它包成 <kind> '<name>' threw: <msg>(SandboxError.message,用于服务端日志),而动作 HTTP 端点在 catch 里把整个包装串原样当作 client 端 error 返回(http-dispatcher.tshandleActions catch),于是调试前缀泄漏到了前端 toast。

改动

  • SandboxError 新增 innerMessage 字段:去掉 <kind> '<name>' threw: 包装、并剥掉默认的 Error: 名字前缀后的纯业务消息。仅「用户代码抛出」的 4 个 threw: 站点填它;沙箱自身的内部错误(能力拒绝/超时/marshal)不填,保持原样。
    • 保留非默认错误名(TypeError: / RangeError: 等)作为「这是真 bug 而非业务规则」的线索。
  • 动作路由:catch 里优先把 innerMessage 回给 client;完整包装串仍打进服务端日志便于排查。

用户现在只会看到「线索信息不完整,提交转商机申请前请补全:终端客户」。

测试

  • packages/runtime 全部单测通过(24/24),新增 SandboxError.innerMessage 断言(.message 留包装、.innerMessage 为纯业务原文)。
  • @objectstack/runtime turbo build(含 DTS 类型构建)通过。

配套修复弹两遍的问题在 objectui: objectstack-ai/objectui#2177。两者独立,各自可单独合入。

@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 3, 2026 5:50am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/s labels Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime.

17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx (via packages/runtime)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/concepts/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/api-reference.mdx (via @objectstack/runtime)
  • content/docs/guides/authentication.mdx (via @objectstack/runtime)
  • content/docs/guides/cloud-deployment.mdx (via @objectstack/runtime)
  • content/docs/guides/deployment-vercel.mdx (via @objectstack/runtime)
  • content/docs/guides/driver-configuration.mdx (via @objectstack/runtime)
  • content/docs/guides/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/guides/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/plugin-chatbot-integration.mdx (via @objectstack/runtime)
  • content/docs/guides/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/guides/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/lifecycle.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@baozhoutao
baozhoutao merged commit 852bc8e into main Jul 3, 2026
16 checks passed
@baozhoutao
baozhoutao deleted the claude/sad-bun-cb465e branch July 3, 2026 08:45
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant