Repository navigation
Commit 6ddb97b
fix(core): actionErrorDetail shows a flat refusal's message, not its bare error code (#37138)
Fixes #37081
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在控制台里,会话失效后某个操作或设置页被拒时,报错不再显示「UNAUTHENTICATED」这个代号,而是显示一句「需要登录才能访问」的英文说明。
- 为什么做:属于“报错要说人话”的体验改进,替所有读这类拒绝答复的设置页与操作按钮解决同一个问题。
- 出错会怎样:最坏是某条报错显示的句子与以前不同(仍是服务器给的原句),不影响数据;可以直接撤回。
- 要你做什么:无。
## What changes
`actionErrorDetail` (`@object-ui/core`) returned a bare-string `error`
before it read `message`. The REST seam's flat 401 body
(`ANONYMOUS_DENY_BODY`, `packages/core/src/security/anonymous-deny.ts`)
is `{error: 'UNAUTHENTICATED', code: 'UNAUTHENTICATED', message:
'Authentication is required to access this endpoint.'}`, so every caller
showed the user the machine code.
Now, when the body carries both a non-empty string `error` and a
non-empty string `message`, the message wins. Everything else keeps
today's order:
- `{error: 'sentence'}` alone still returns the sentence (the legacy
`/actions` shape).
- `{error: {message}}` (the ADR-0112 nested envelope) is read as before,
and still ahead of a top-level `message`. No body shape on the platform
was found that carries both a nested `error.message` and a different
top-level `message`, so that order is kept.
- An empty or non-string `message` beside a string `error` returns the
`error`; nothing readable returns the caller's fallback.
Callers (all read through this one function, none changed):
`useConsoleActionRuntime.tsx`, `FlowItemMoreMenu.tsx`,
`sharing-rule-catalog.ts`, `catalog-activation.ts`,
`permission-set-clone.ts`, `packagedActionLedger.ts`,
`connectorConnections.ts`, `connectorCredentials.ts`,
`packagedFlowLedger.ts`, `flowResponse.ts` (app-shell) and
`actionResponse.ts` (core).
Files to read first:
1. `ui/packages/core/src/actions/actionErrorDetail.ts` — the one changed
branch (the bare-string `error` case).
2.
`ui/packages/core/src/actions/__tests__/actionErrorDetail-37081.test.ts`
— the pins.
Two-minute verification: `cd ui && pnpm exec vitest run
packages/core/src/actions/__tests__/actionErrorDetail-37081.test.ts` —
expect 5 passed.
## Tests
New file `actionErrorDetail-37081.test.ts` (no existing harness pins
`actionErrorDetail` directly), five cases: the flat 401 body returns its
message; `{error: 'sentence'}` alone returns the sentence; empty or
non-string `message` returns the `error`; the nested envelope is
unchanged and still beats a top-level `message`; lone `message` and the
fallback are unchanged.
Flipped pins: none. No existing test asserted the code-over-message
order. Two checks: a static scan of every `ui/**` test for an object
literal carrying both a string `error` and a string `message` found 8
hits, none routed through `actionErrorDetail` (the `data-objectstack`
and `AuditLogPage` / `PackagesPage` fixtures use their own readers); and
the 113 test files that name a caller module or the code
`UNAUTHENTICATED` in app-shell / console all pass with the change.
<details><summary>Readings at 39f1bca</summary>
- `cd ui && pnpm exec vitest run packages/core/` — Test Files 247 passed
(247), Tests 4774 passed, 27 skipped; exit 0.
- `cd ui && pnpm exec vitest run` over the 113 caller test files — Test
Files 113 passed (113), Tests 1564 passed; exit 0.
- `pnpm exec turbo run type-check --filter=@object-ui/core` —
`@object-ui/core:type-check` executed (cache miss), Tasks 4 successful;
exit 0.
- `pnpm --dir ui exec vitest run scripts/` after the seven-package Test
UI build — Test Files 172 passed, 2 skipped; Tests 5131 passed; lock
VERDICT command-exit 0.
- Ablation (fix committed first; `scripts/ablation-replace.mjs --delete`
on the new `return b.message` line, anchor 1 -> 0, blob 03bc828 ->
7c90c74a): the flat 401 pin went red, `Expected: "Authentication is
required to access this endpoint." Received: "UNAUTHENTICATED"`, 1
failed / 4 passed; restore verified blob == HEAD, `git diff HEAD` empty.
</details>
## Acceptance notes
- `@object-ui/core` does not depend on `@objectstack/core`, so the pin
copies `ANONYMOUS_DENY_BODY` field for field and names its source file.
## Verification
Derived gate families (`dispatch-gates --commands` at 39f1bca, 38): 37
run locally with exit 0, including `pnpm --dir ui exec vitest run
scripts/` after the seven-package Test UI build. `pnpm
check:type-check-debt` is NOT MEASURED locally: its first run exited 3
(PREREQUISITE NOT MET, its closure build got no turn on the shared
verify lock) and two locked retries timed out in the queue (exit 99). It
runs in CI under Lint and Repo Gates; read it there. `dispatch-gates
--ran` reconciles 38 of 38. `overlap-check`: clean. Repo-wide families
run in CI.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 355c73c commit 6ddb97b
3 files changed
Lines changed: 78 additions & 1 deletion
File tree
- .changeset
- ui/packages/core/src/actions
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
30 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
| |||
0 commit comments