fix(app-shell): entitlement 错误上下文只读 error.details.*,删除平铺双方言回退(#3329) - #3353
Merged
Merged
Conversation
cloud#1046 两仓变更的 objectui 先行半边。entitlement 键 (upgrade_url / contact_url / plan / current / limit)从 `error.<key>` 顶层改为 `error.details.<key>` 唯一位置,并删除 `entitlementErrorFields()` 的 `body?.error ?? body` 平铺容错 —— 变更后只接受一种形状,不留 `??` 回退。 `code` / `message` 是 ApiErrorSchema 的声明字段,仍留在 `error` 上。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015W6nhsDrz6zWQc8je12a1t
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 #3329
cloud#1046 两仓协调变更的 objectui 先行半边(strict 版,按 issue 里的默认执行,否决窗口未被使用)。
改了什么
packages/app-shell/src/environment/entitlements.tsentitlement 业务上下文(
upgrade_url/contact_url/plan/current/limit)全部改从error.details.KEY这一个位置读取(原先是error.KEY顶层)。那些键坐在error上是未声明的兄弟键 —— 它们能「解析通过」纯粹是因为ApiErrorSchema是普通z.object、会剥掉未知键,而这条路径消费的是 parse 之前的裸 wire body:合规是靠蒸发,不是靠声明。details是 ADR-0112 为结构化错误上下文声明的槽(framework#4224、cloud#930 的AiErrorExtra先例)。code/message是ApiErrorSchema的声明字段,仍留在error自身上,未随迁。删除
entitlementErrorFields()(body?.error ?? body)。变更后只有一种可接受形状:{ "success": false, "error": { "code": "DEV_ENV_LIMIT", "message": "…", "httpStatus": 403, "details": { "current": 3, "limit": 3, "upgrade_url": "…" } } }没有新增任何
??跨形状回退 —— 一个宽容的消费端在这里买不到任何东西(见下方时序),却会把已退役的方言固化成第二份事实契约,正是 cloud#944 在退役的多方言漂移。扫读点结果(issue 第 4 条)
按真实键名全仓扫了
upgrade_url/contact_url/seatCount/plan/current/limit/entitlement与三个错误码。除本 PR 改的这一条外,没有第二个错误体读点:useConsoleActionRuntime.tsx:331是唯一调用方(喂进去的是res.json()的裸 body),不含独立读点,只更新了它的测试;EnvironmentEntitlementDialog.tsx渲染的是已成形的EntitlementDialogSpec,不碰 wire 键;useEnvironmentEntitlements.ts/CloudOnboardingNext.tsx/provisionEnvironment.ts读的是GET /cloud/environment-entitlements的成功体data.*(含seatCount),不是failWithCode的错误体 —— 不在本次迁移范围;它们各自的json?.data ?? json成功包络容错另行记录为 app-shell:/cloud/environment-entitlements成功包络仍有json?.data ?? json双方言容错(3 处),与 cloud#944/#1046 的收口方向相反 #3352(未认领),本 PR 不动。entitlement一词全仓只作 i18n key 前缀(environment.entitlement.*),无 wire 读点。测试
packages/app-shell/src/environment/__tests__/entitlements.test.ts新增reads error.details and nowhere else一组严格性 pin,现有用例全部改写为details形状:details里的upgrade_url/contact_url/plan/current/limit被读到;code的兄弟位 → 弹窗照开(code没搬),但每个上下文键都降级到默认值(CTA 落回/settings/billing、不出「3 of 3」计数、plan 降回 free);PRODUCTION_ENV_LIMIT的兄弟位contact_url→ CTA 直接undefined;error是字符串、code在顶层)→ 返回null,走调用方的普通报错路径;error包络的裸 body →null;details不是对象 → 不去别处捞,取默认值。useConsoleActionRuntime.test.tsx补一条端到端 pin:退役的平铺形状 不开弹窗,而是返回{ success: false, error: '…' }(红 toast 路径)。实跑输出:
时序 —— 合并后请知会 cloud 分片
本 PR 合入 objectui
main后托管 Console 不会立刻变:cloud 镜像按.objectui-sha钉扎。cloud#1046 的后半(收口extra+ 5 个调用点改details+ 断言重写)将与 pin bump 同一个 PR 落地,生产者/消费者在托管产品里原子切换,无中间窗口。本 PR 合并即解除 cloud#1046 的 Blocked-by。Breaking(已写进 changeset)
.changeset/entitlement-error-context-reads-details.md(minor—— 按 AGENTS.md 版本策略,objectui 自身的破坏性变更也标 minor,语义写在正文)。跟踪 objectui
main但控制面落后于 cloud#1046 的自托管部署:弹窗仍会打开、标题/正文不变(code没搬),但会丢上下文 —— 升级 CTA 落回/settings/billing、PRODUCTION_ENV_LIMIT掉「Contact sales」、DEV_ENV_PLAN_LOCKED一律说「free plan」、DEV_ENV_LIMIT不再报「using X of Y」。把控制面升过 cloud#1046 即恢复。这是 issue 里给出否决窗口后按 strict 默认执行的结果。🤖 Generated with Claude Code
https://claude.ai/code/session_015W6nhsDrz6zWQc8je12a1t