Repository navigation
fix(app-shell): entitlement 成功包络严格只读 data,删除 3 处双方言容错 (#3352) - #3377
Merged
Merged
Conversation
…itlement read-points (#3352) The control plane wraps every success body as `{ success, data }` (cloud#1046), and `EnvironmentEntitlementsSummary` is declared as that `data` payload. Three Console read-points still accepted a bare body as a second dialect: - useEnvironmentEntitlements.ts `json?.data ?? json` - CloudOnboardingNext.tsx `json?.data ?? json` - provisionEnvironment.ts `'data' in body ? body.data : body` A missing envelope therefore degraded silently: every field reads `undefined`, so `hasProductionEnv` becomes `false` and a user with a live production environment is told they have none. Each site now reads `data` only and falls to its own existing failure branch when it is absent — row-derived fallback, `phase: 'unknown'`, and a throw into the caller's lazy-provision path respectively. Same direction as #3329, which removed the error-body half. 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. |
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 #3352
做了什么
控制面的成功响应按契约一律包成
{ success, data },Console 侧却有 3 处读点「两种形状都收」。本 PR 把它们改成严格只读data,拿不到就走各自既有的失败分支——逐处保留原语义,不统一成一种:data时environment/useEnvironmentEntitlements.tsjson?.data ?? jsonnull→fromRows()行派生回退console/home/CloudOnboardingNext.tsxjson?.data ?? jsonphase: 'unknown'→ 降级为两个按钮都给console/organizations/provisionEnvironment.ts'data' in body ? body.data : body为什么
这是 #3329(错误体半边,删
entitlementErrorFields()的body?.error ?? body)的同族收尾,方向一致:一种形状,严格读。??容错把一个事实上不存在的第二方言固化成了第二份事实契约,而且失败是静默的:一旦生产者漏包data,裸 body 的字段全是undefined,hasProductionEnv直接读成false——一个明明有生产环境的用户会被告知「还没有生产环境」,并被推到错误的 "Create your environment" CTA 上,没有任何一处会响。provisionEnvironment那处更直接:原本会把裸 body(甚至{})当成功的 env 返回,报告一次「provision 成功」却什么都没带回来。契约优先(AGENTS.md 准则 #0.1):这类漏包是生产者侧的 bug,消费端的宽容只会把它藏起来。
契约核实(第 1 步)
cloud 仓不在本会话凭证范围内,改用 in-scope 证据链定案,三条互相印证:
environment/entitlements.ts:181上的注释就写着EnvironmentEntitlementsSummary是 “GET /cloud/environment-entitlements →data”。summary 的宿主位置在类型声明层面本来就只有data一个,裸 body 分支从来没有 spec 依据。error.details.*并删除平铺双方言回退(cloud#1046 两仓变更的 objectui 先行半边) #3329 已按 strict 合入本仓——其 PM 验收评论明确记录「无任何??跨形回退」,并把本单点名为「同一清理方向的下一单」。线程内未发现任何相悖事实(例如「某端点未包信封」)。控制面是 SaaS 单版本部署,不存在 #3366 那种客户端跨代服务端存活的兼容窗口。
测试
三处各补了裸 body 的负向 pin,另新建了
useEnvironmentEntitlements的测试文件(此前该 hook 无测试)。反向验证方向事先预判为「全红」,实测与预判一致:把三条
??/'data' in body限枝恢复成origin/main的写法后,6 条新 pin 全部转红,9 条既有/形状无关的测试保持绿:恢复实现后:
Test Files 3 passed (3) / Tests 15 passed (15)Test Files 276 passed (276) / Tests 2414 passed | 1 skipped (2415)type-check(tsc --noEmit+ typetests):干净退出其中
useEnvironmentEntitlements那条 pin 特意让裸 body 声称hasProductionEnv: false,而行数据里确有生产环境——严格读之后由行派生回退解析出true,正好把「静默读错」这个后果本身钉住。关于 changeset
不带 changeset。按仓库约定纯 bug 修复不需要;且在生产者遵守契约的前提下无用户可见行为变化——三处的失败分支都是既有路径,没有新增/改写任何 UI 文案。
provisionEnvironment新增的抛错被调用方CreateWorkspaceDialog既有的try/catch(console.warn后继续onCreated)吞掉,不产生新的用户可见面。范围
严格限于 issue 指定的 3 个读点 + 相应测试,未越界。
Generated by Claude Code