Repository navigation
Commit acc9c57
fix(app-shell): show the explain refusal's message instead of blanking the Access panel (#27012)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ85kpgfqxzRKnovzXGcQbacp)_
Fixes #26805
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:Studio「权限说明」面板在服务端返回非 403 拒绝时,改为读取错误信封里的 message
显示,而不是整个面板消失。
- **为什么改**:管理员把对象名打错(404)、参数不合法(400)或服务端出错(500)时,面板直接变空白、没有任何提示,无从下手。
- **风险与回滚**:风险低,只改一个面板的出错文案读取,复用已有的共享读取器;回滚即还原本 PR 的一个提交。
- **先看**:`AccessExplainPanel.tsx` 的 `if (!res.ok)` 分支与 `catch`;新测试
`AccessExplainPanel.refusalEnvelope-26805.test.tsx`。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/AccessExplainPanel.refusalEnvelope-26805.test.tsx`,预期
8 个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
`AccessExplainPanel` (Studio Access pillar) built its failure text from
`data.message || data.error`. The explain door refuses in the ADR-0112
envelope, `{ success: false, error: { code, message } }`, where `error`
is an object: it reached `setError`, rendered as a React child and
unmounted the sheet, so any non-403 refusal left a blank panel.
- The `!res.ok` branch now asks the shared app-shell reader
`readEnvelopeFailureText` (`utils/apiErrorEnvelope.ts`) first, the same
reader the package surfaces and the AI publish path use. ⛔ No new copy,
and the shared reader is unchanged: it returns `null` for non-envelope
bodies by design, and its header asks each caller to keep its own legacy
rungs and fallback on its own line. So the panel keeps its two flat
rungs (top-level `message`, bare-string `error`), now typed so only a
string can pass, then the existing `HTTP STATUS STATUS_TEXT` line. This
is the `PackagesPage` publish call site's spelling.
- The `catch` hands `setError` a string only: an `Error`'s non-empty
message, otherwise `String(err)`. Before, a rejection whose `message`
was not a string reached state as-is.
- The 403 branch is untouched: it still shows the localized
delegated-scope sentence.
- No server change and no change to the explain request.
## Tests
New file `AccessExplainPanel.refusalEnvelope-26805.test.tsx` (8 cases),
on the existing panel harness (faked authenticated fetch):
- nested envelope 404 `OBJECT_NOT_FOUND`, 400 `VALIDATION_FAILED`, 500
`INTERNAL_ERROR`: the alert carries the server message and code, never
`[object Object]`, and the panel's form is still mounted;
- flat `{ message }` 404 still shows its message;
- non-JSON 500 falls back to `HTTP 500 Internal Server Error`;
- 403 in the nested envelope keeps the delegated-scope sentence;
- a rejected request shows its `Error` message; a non-`Error` rejection
leaves the panel mounted with an alert.
## Acceptance notes
- The shared reader appends the declared code in parentheses (`Object
'x' not found (OBJECT_NOT_FOUND)`), as on every other surface that uses
it.
- Seven pre-existing eslint warnings in `AccessExplainPanel.tsx` sit on
lines this diff does not touch; none are added.
## Verification
All runs on head `b394f525`, worktree from `origin/main` `fd246c22`,
after building the `@object-ui/app-shell` dependency closure under the
verify lock (exit 0).
<details><summary>Tests, typecheck, lint</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2
packages/app-shell/src/views/metadata-admin/AccessExplainPanel
packages/app-shell/src/utils/apiErrorEnvelope.test.ts`: Test Files 8
passed (8), Tests 70 passed (70), lock VERDICT command-exit 0.
- `pnpm --filter @object-ui/app-shell run type-check` (both `tsc
--noEmit` and `tsconfig.test.json`): VERDICT command-exit 0.
- `pnpm --dir ui exec eslint` on both files: exit 0, 0 errors, 7
warnings, all pre-existing.
- `pnpm --dir ui run check:new-line-citations`: 0 new citations, exit 0.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, restored to
the HEAD blob each time)</summary>
1. The `!res.ok` expression restored to the old `(data?.message as
string) || (data?.error as string) ||`: the three nested-envelope cases
go red (404, 400, 500), the other 5 stay green. Restore verified: blob
`c46dd278cdf3` equals HEAD, `git diff HEAD` empty.
2. The `catch` restored to `(err as Error)?.message ?? String(err)`: the
non-`Error` rejection case goes red, 7 stay green. Same restore proof.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 24 commands; each ran with its exit
captured before any pipe (`pnpm --dir ui exec vitest run scripts/` under
the verify lock). `--ran` reconciliation: 24 derived, 24 run, 0
NOT-MEASURED, 0 UNRUN. Model tier: no path-derived mandate.
- `node scripts/check-closing-keyword-parity.mjs` exit 0
- `node scripts/check-closing-keyword-parity.mjs --self-test` exit 0
- `node scripts/check-comment-mask-corpus.mjs` exit 0
- `node scripts/check-sdui-manifest.mjs` exit 0
- `node scripts/check-sdui-manifest.mjs --self-test` exit 0
- `pnpm --dir ui exec vitest run scripts/` exit 0
- `pnpm --filter @objectstack/spec run check:duration-unit-keys` exit 0
- `pnpm check:cross-package-test-inputs` exit 0
- `pnpm check:dispatcher-error-vocabulary` exit 0
- `pnpm check:driver-memory-census` exit 0
- `pnpm check:engine-double-contract` exit 0
- `pnpm check:gitlink-declared` exit 0
- `pnpm check:nul-bytes` exit 0
- `pnpm check:published-files` exit 0
- `pnpm check:query-options-erasure` exit 0
- `pnpm check:refd-timer-probe` exit 0
- `pnpm check:skill-identifier-liveness` exit 0
- `pnpm check:test-source-alias` exit 0
- `pnpm check:tier-file-adoption` exit 0
- `pnpm check:type-check-coverage` exit 0
- `pnpm check:type-check-debt` exit 0
- `pnpm check:undeclared-dep-imports` exit 0
- `pnpm check:watch-hint-literal` exit 0
- `pnpm check:where-matcher` exit 0
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (changed files linted;
repo-wide lint is CI's)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset.
(`@object-ui/app-shell` is private: no changeset)
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English (the maintainer summary
is Chinese by the dispatch contract).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbWZov36PsY1JbrTDA6)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4bce21d commit acc9c57
2 files changed
Lines changed: 154 additions & 2 deletions
File tree
- ui/packages/app-shell/src/views/metadata-admin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
458 | 459 | | |
459 | 460 | | |
460 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
461 | 467 | | |
462 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
463 | 472 | | |
464 | 473 | | |
465 | 474 | | |
| |||
468 | 477 | | |
469 | 478 | | |
470 | 479 | | |
471 | | - | |
| 480 | + | |
472 | 481 | | |
473 | 482 | | |
474 | 483 | | |
| |||
0 commit comments