Repository navigation
fix(console): settings 客户端跟进 framework#3843 响应信封,配置板块整体恢复 (#3366) - #3372
Merged
Merged
Conversation
…ope (#3366) All five `/api/settings` responses moved into the platform's declared `{ success, data }` envelope; the console's settings client is a raw `fetch` caller and never took the `body.data` hop, so it handed the envelope itself to the views. Every namespace page threw `Cannot convert undefined or null to object` out of `Object.entries(payload.values)` and went to the error boundary, while the hub's `manifests ?? []` turned the same body into a false "no settings are registered" empty state. - `jsonOrThrow` unwraps with the exact `ObjectStackClient.unwrapResponse` predicate (boolean `success` AND `data` present). Requiring both is what leaves error envelopes intact, so `err.payload.error` still feeds the locked-key and per-field rejection rendering (objectstack#4224); a body with no boolean `success` is a pre-#3843 server and passes through. - `runSettingsAction` reads the verdict from `data` on the success arm and from `error.details` on the reported-failure arm, where the route parks the whole result so `message`/`severity`/`details` survive the 400. - Each endpoint asserts the shape it promises and throws a named `Malformed response from …` instead of passing a wrong-shaped body on — both views already render an error state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
… the compat branch Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
marked this pull request as ready for review
August 5, 2026 10:26
This was referenced Oct 2, 2026
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.
Fixes #3366
问题
framework#3843 把
service-settings的 5 个响应全部搬进平台声明信封{ success, data },其 changelog 明说了 raw fetch 调用方要付的代价:必须加一跳body.data。console 的 settings 客户端正是 raw fetch 调用方,没跟进,于是把信封本身当 payload 交给了视图:Object.entries(payload.values)上抛Cannot convert undefined or null to object,整页落到错误边界;r.manifests ?? []把同一个坏 body 变成假空态「尚未注册任何设置」—— 比白屏更误导,会把排查方向带去「插件没注册」;message/severity丢失,toast 只剩 HTTP status text。前提已对
origin/main@68b6a28复核成立(api.ts的jsonOrThrow直接return res.json();SettingsView.tsx:97直取payload.values),服务端一侧也已核对:settings-routes.ts5 条路径全部走sendOk/sendError。改法
生产代码只动
apps/console/src/pages/settings/api.ts一个文件 —— 视图未改,客户端修好后SettingsView/SettingsHub原样工作:jsonOrThrow统一解包,判定与ObjectStackClient.unwrapResponse逐字相同:success是 boolean 且 存在data。两个条件都要,正是错误信封不被解包的原因 —— 失败体是{ success: false, error },没有data,原样交回,err.payload.error继续喂 objectstack#4224 的 locked key 与逐字段拒绝渲染。没有 booleansuccess的 body 是 fix(app-shell,components): 服务端声明动作的 visible 门按「已声明」判定,visible: false 不再渲染 (#3835) #3843 之前的服务端,原样透传。runSettingsAction两臂各读各的:成功臂从data取 verdict,上报失败臂从error.details取 —— 路由正是把整个 SettingsActionResult 放在那里,好让 message / severity / details 熬过 400。Malformed response from …,而不是把坏 body 继续往下传。两个症状本质都是「读不了的 body 冒充读得了的往下走」;两个视图本来就有 error 态,具名错误落得进去。契约优先的说明:这里的两代兼容不是在消费者侧加宽容别名,而是复用平台客户端自己的同一条判定 —— console 是带版本的静态资产,会跨服务端版本存活。旧形状分支被测试逐条钉住:等最老支持的服务端都带上 #3843,删掉它是一条红测试点名它在替哪代服务端兜底,而不是静默回归。
测试
新增
api.envelope.test.ts(19 例,单元)与__tests__/SettingsView.envelope.test.tsx(5 例,过真实./api+ stub fetch 的两屏集成)。覆盖 PM 点名的三面:信封形正确解包、旧裸形仍兼容、错误响应(success:false/ 非 2xx)不被解包逻辑吞掉。反向验证(方向在跑之前先定:普通的「红」方向)。只把
jsonOrThrow里那一跳解包退回return res.json():8 条红全部是喂信封形 body 的用例(list / namespace / save 三处解包 + 两屏渲染),裸形、错误路径、动作三组 25 条保持绿 —— 动作那组本来就走自己的解包路径,不受这一跳影响,与预测一致。
再把形状断言一并停用(还原成本次修改之前的真实状态),集成测试复现的是 issue 里那条一模一样的浏览器崩溃栈:
也就是说这两个测试文件钉的是真 bug,不是绕着修改写的同义反复。
影响面清点
这个客户端的消费半径是封闭的:仅
SettingsView/SettingsHub/ 同目录测试 import 它,仓内没有第二处 raw fetch 读/api/settings。顺手核对了 console 另外两处直读顶层 body 的 raw fetch(/auth/me/localization、/forms/:slug),服务端确认这两条路由本就返回裸 body(未走sendOk),不属同一族问题,无需改动、也无 finding 可报。用户可见,已附 changeset(
@object-ui/console: patch;按仓库约定不声明 major)。Generated by Claude Code