Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit fffa30d

Browse files
claude[bot]os-support-aiclaude
authored
fix(data-objectstack): a refused view read is not an object with no saved views (#8901)
* feat(data-objectstack): discriminate a refused view read from an object with no saved views `ObjectStackAdapter.listViews` degraded every failure to an empty list, so a refused (401/403) or broken (5xx, dropped connection) `view` read returned the identical value as a list the server served empty — and every consumer reads only the return. That is the swallow objectui#7741 removed from `listImportMappings` one method over; here it renders as an object's view switcher showing no saved views at all, including ones the user created. The degrade stays. What is added is the discrimination, read from `err` itself rather than from the emptiness of the result: - `classifyViewsFailure(err)` — a separate reading, not a second caller of `classifyImportMappingsFailure`. `view` is in the platform's static spelling contract, so the metadata list door's 400 `INVALID_REQUEST` ("this deployment carries no such kind") is unreachable for it; carrying that quiet arm over would swallow a real refusal. Only a host with no `/meta` door stays quiet. - `MetadataReadWarningEvent.operation` / `.kind` gain their second members — the additive, reviewed widening the single-member unions were built for. - `MetadataReadFailureKind`, with `ImportMappingsFailureKind` now its alias. - `metadataReadWarningToast` picks title and remedy by `operation`, so a views failure no longer renders the import-mapping sentence. Three new `console.savedViews*` keys in all ten locale packs. Refs objectui#8151. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH * fix(scripts): re-derive the UNGATED_EXAMPLES key this branch's line insert moved `scripts/check-doc-example-types.mjs`'s ledger is keyed by `path:line symbol`. This branch inserts +262/-23 lines into `packages/data-objectstack/src/index.ts`, which pushed `createObjectStackAdapter`'s `@example` block down, so the stored key stopped resolving and `scripts/__tests__/check-doc-example-types.test.ts` went red on "every row names a block that is actually in the compiled tier". The key was located by FILE + SYMBOL and its new value re-derived from the checker's own extractor — `ledgerKey(block)` over `exampleCensus()` — never from a line number read off a report. Ledger row count 90 -> 90, zero executable change. Re-measured on this branch: exactly one ledger row names a file this branch touches; `metadataReadWarningToast.ts` and the ten locale packs have none. The tree-wide census has no discriminating power over this class: it reads prose citations, and this is a stored literal used as a key. The test that separates them is stored-vs-computed — a `path:line` assembled at runtime to print a diagnostic cannot go stale, one persisted and compared for equality can. Refs objectui#8151. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH * fix(scripts): re-baseline the `i18n-locales` per-chunk ceiling onto both admitted claimants `PER_CHUNK_GZIP_CEILINGS['i18n-locales']` 455,000 -> 465,000 and `PER_CHUNK_BASELINE['i18n-locales']` 446,076 -> 456,196, moved together in one commit as that file requires. The ten locale packs' citation of the retired headroom is updated in the same change so it cannot go stale again: it now names no figure at all, which is the form the file's own anti-drift rule allows. Four console builds, one container, one instrument -- `i18n-locales` read out of the `apps/console/dist/eager-closure.json` each build writes: bbe285e main 454,602 (headroom 398) 3949cf3 main + objectui#8901 455,271 +669, over by 271 ea5eab7 main + objectui#8888 455,519 +917, over by 519 ba20b0bc0 main + BOTH 456,196 +1,594, over by 1,196 The two deltas sum to 1,586 against a measured 1,594: two independent claimants on this chunk are additive to within 8 bytes, which is the fact a shared budget needs and the one a per-pull-request reading cannot produce. Sized at 8,804 bytes of headroom = 0.10x REGRESSION_THIS_GATE_MUST_CATCH_BYTES, this key's own convention and marginally tighter than the 8,924 (0.10x) the retired pair carried. NOT sized at the 804 bytes the overage needed: a line with ~0 headroom is what objectui#8816 was filed about -- it reddens whichever in-flight pull request is weighed second and blames that diff for arithmetic that is not its own. Trimming was measured first and cannot reach 1,196 bytes inside these changes: best key reuse is 128 bytes for objectui#8888 and there is no reuse candidate at all for objectui#8901. The payload reduction that would make the next raise unnecessary is real but is not this: `check:i18n-dead-keys` reports 127 confirmed dead keys in ten packs, and `@object-ui/i18n` publishes them, so removing one is a published-surface decision that needs its own card. Nothing else moved: not REGRESSION_THIS_GATE_MUST_CATCH_BYTES, not the other three per-chunk ceilings, not MAX_EAGER_CLOSURE_GZIP_BYTES (the aggregate holds 23,507 bytes of headroom, 0.26x, with both claimants on it). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH --------- Co-authored-by: os-zhuang <support@objectstack.ai> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 0073423 commit fffa30d

17 files changed

Lines changed: 1102 additions & 94 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
'@object-ui/data-objectstack': minor
3+
'@object-ui/app-shell': minor
4+
'@object-ui/i18n': minor
5+
---
6+
7+
`listViews` no longer renders a refused metadata read as "this object has no saved views"
8+
(objectui#8151).
9+
10+
`ObjectStackAdapter.listViews` degrades every failure to an empty list, and every consumer
11+
reads only the return. So "the server served zero saved views" and "the server refused, or
12+
broke" produced the identical UI — with a `console.warn` as the only discriminator, in the
13+
browser console, with nothing pointing at it. It is the same defect objectui#7741 removed
14+
from `listImportMappings` one method over, and the user-visible cost is the higher one: an
15+
empty `listViews` is an object's **view switcher**, so a user whose token lapsed
16+
mid-session could be shown an object that appears to have no saved views at all —
17+
including views they created themselves.
18+
19+
**The empty-list return is unchanged.** `listViews` still answers `Promise<any[]>` and
20+
still never throws, on every arm including the loud ones — this is a channel added
21+
ALONGSIDE that contract, not a change to it. `listImportMappings` is likewise unchanged,
22+
down to its wording.
23+
24+
- **`ObjectStackAdapter.listViews` now emits on `onMetadataReadWarning`** — the channel
25+
objectui#7741 added — when the read failed in a way that is not the supported "this host
26+
mounted no metadata door" shape. The event carries the object, whether the server
27+
`refused` this caller or the answer was `unreadable`, and the server's own ADR-0112
28+
code, HTTP status and message.
29+
- **New: `classifyViewsFailure(err)`.** A SEPARATE reading, deliberately not a second
30+
caller of `classifyImportMappingsFailure`: `view`'s quiet set is strictly smaller. The
31+
arm the mapping classifier is built around — 400 `INVALID_REQUEST`, the metadata list
32+
door's "this deployment carries no such kind" — is unreachable for `view`, which is in
33+
the platform's static spelling contract, so reading it as kind-absence would swallow a
34+
real refusal. On `view`, only a host with no `/meta` door at all stays quiet.
35+
- **`MetadataReadWarningEvent`'s `operation` and `kind` gain their second members**
36+
(`'listViews'` / `'view'`). This is the additive, reviewed widening the single-member
37+
unions were designed for, and it worked as designed: the consumer that renders these
38+
events had a `switch` naming one operation, so the widening turned "a views failure is
39+
toasted as an import-mapping failure" into a compile error rather than a runtime lie.
40+
- **New: `MetadataReadFailureKind`**, the neutral spelling of the three verdicts.
41+
`ImportMappingsFailureKind` is now an alias of it — identical members, so existing
42+
consumers are unaffected in both directions.
43+
- **The console says which list it was.** `metadataReadWarningToast` picks its title and
44+
its remedy by `operation`, so a failed view read reads *"Saved views for {{object}}
45+
could not be loaded … not because this object has no saved views"*. Three new
46+
`console.savedViews*` keys ship in all ten locale packs; the `console.importMappings*`
47+
copy is untouched.
48+
49+
This applies framework #13906 decision 1 option A — *a thing that could not be READ is not
50+
a thing that is ABSENT* — at the second seam that needed it.

‎packages/app-shell/src/providers/metadataReadWarningToast.test.ts‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,114 @@ describe('emitMetadataReadWarning (objectui#7741)', () => {
137137
expect(options.duration).toBe(10_000);
138138
});
139139
});
140+
141+
/**
142+
* The SECOND emitter on this channel (objectui#8151).
143+
*
144+
* `listViews` carried the same swallow one adapter method over, and adding it
145+
* to `MetadataReadWarningEvent`'s `operation` union is the widening
146+
* objectui#7741 kept that union single-member FOR. This block is that widening
147+
* arriving at its consumer: the pins below are about which SENTENCE a views
148+
* failure gets, and — just as load-bearing — about the mapping sentences not
149+
* moving while it happened.
150+
*/
151+
const VIEWS_REFUSED: MetadataReadWarningEvent = {
152+
operation: 'listViews',
153+
kind: 'view',
154+
objectName: 'crm_lead',
155+
reason: 'refused',
156+
code: 'UNAUTHENTICATED',
157+
status: 401,
158+
message: 'authentication required',
159+
};
160+
161+
describe('emitMetadataReadWarning — the listViews emitter (objectui#8151)', () => {
162+
it('⭐ denies the reading the empty list invites: not "this object has no saved views"', () => {
163+
// The user's actual question in front of a view switcher is "where did my
164+
// views go?" — so the sentence has to answer THAT, not the import wizard's
165+
// question about whether anything is registered.
166+
const s = sink();
167+
168+
emitMetadataReadWarning(VIEWS_REFUSED, t, s);
169+
170+
const [title, options] = s.warning.mock.calls[0];
171+
expect(title).toBe('Saved views for crm_lead could not be loaded');
172+
expect(options.description).toContain('could not be read');
173+
expect(options.description).toContain('no saved views');
174+
expect(options.description).toContain('Sign in again');
175+
});
176+
177+
it('⛔ never renders the import-mapping wording for a views failure', () => {
178+
// The exact runtime lie the closed `operation` union existed to prevent:
179+
// before this card the title was one hard-coded `importMappingsUnavailable`,
180+
// so a second emitter would have toasted "Saved import mappings for
181+
// crm_lead could not be loaded" with nothing failing to compile.
182+
const s = sink();
183+
184+
emitMetadataReadWarning(VIEWS_REFUSED, t, s);
185+
186+
const [title, options] = s.warning.mock.calls[0];
187+
expect(title).not.toContain('import');
188+
expect(String(options.description)).not.toContain('registered');
189+
});
190+
191+
it('says retry-and-report on an unreadable views answer', () => {
192+
const s = sink();
193+
194+
emitMetadataReadWarning({ ...VIEWS_REFUSED, reason: 'unreadable', code: undefined, status: 500 }, t, s);
195+
196+
const [, options] = s.warning.mock.calls[0];
197+
expect(options.description).toContain('no saved views');
198+
expect(options.description).toContain('Try again');
199+
expect(options.description).not.toContain('Sign in again');
200+
});
201+
202+
it("carries the server's own words on this arm too", () => {
203+
const s = sink();
204+
205+
emitMetadataReadWarning(VIEWS_REFUSED, t, s);
206+
207+
const [, options] = s.warning.mock.calls[0];
208+
expect(options.description).toContain('UNAUTHENTICATED');
209+
expect(options.description).toContain('HTTP 401');
210+
});
211+
212+
it('refuses an unhandled operation rather than rendering another read’s sentence', () => {
213+
// Same discipline as the unhandled-reason pin, one level up. Unreachable
214+
// for a type-checked caller; reachable for a JS one.
215+
const s = sink();
216+
217+
expect(() =>
218+
emitMetadataReadWarning(
219+
{
220+
...VIEWS_REFUSED,
221+
operation: 'listSomethingElse' as unknown as MetadataReadWarningEvent['operation'],
222+
},
223+
t,
224+
s,
225+
),
226+
).toThrow(/no title for operation/);
227+
});
228+
229+
it('⭐ THE LIT CONTROL — the import-mapping copy is byte-identical to what objectui#7741 shipped', () => {
230+
// A widening that quietly reworded the sibling's toast would pass every
231+
// pin above. These three strings are the ones objectui#7741 put in `en`,
232+
// asserted whole rather than by substring.
233+
const s = sink();
234+
235+
emitMetadataReadWarning(REFUSED, t, s);
236+
237+
const [title, options] = s.warning.mock.calls[0];
238+
expect(title).toBe('Saved import mappings for crm_plant_cost could not be loaded');
239+
expect(String(options.description).split('\n')[0]).toBe(
240+
'The server refused this request, so this list is empty because it could not be read — not because nothing is registered. Sign in again, or ask an administrator for access.',
241+
);
242+
243+
const s2 = sink();
244+
emitMetadataReadWarning({ ...REFUSED, reason: 'unreadable', code: undefined, status: undefined, message: undefined }, t, s2);
245+
const [, options2] = s2.warning.mock.calls[0];
246+
expect(options2.description).toBe(
247+
'This list is empty because it could not be read, not because nothing is registered. Try again, and report this if it keeps happening.',
248+
);
249+
});
250+
});

‎packages/app-shell/src/providers/metadataReadWarningToast.ts‎

Lines changed: 123 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,25 @@
2828
* misreading. Promoting the log level would not have changed any of it. This
2929
* module is the half that makes the failure visible where the decision is made.
3030
*
31+
* ## The same surface, a second read (objectui#8151)
32+
*
33+
* `listViews` carried the identical swallow, and its cost is the higher one: an
34+
* empty view list is an object's VIEW SWITCHER, so a user whose token lapsed
35+
* mid-session was shown an object that appears to have no saved views at all —
36+
* including views they created. It is the second emitter on this channel, and
37+
* every string below is chosen by WHICH read failed rather than shared, because
38+
* a hedged sentence about "a list" would put the ambiguity back in the copy
39+
* after the event removed it from the data.
40+
*
3141
* ## What it deliberately does NOT say
3242
*
33-
* Nothing about the supported case. A server that does not serve the `mapping`
34-
* kind never reaches here — the adapter classifies that arm as `not-served` and
35-
* emits no event — so an older deployment keeps its quiet, empty, selector-less
36-
* wizard and earns no toast. Turning a real deployment shape into a visible
37-
* fault is the failure this surface must not commit.
43+
* Nothing about the supported case. The adapter classifies that arm as
44+
* `not-served` and emits no event at all, so a deployment in a real, supported
45+
* shape earns no toast — turning one into a visible fault is the failure this
46+
* surface must not commit. ⚠️ WHICH failures are in that arm is decided per
47+
* read and is not the same set twice: a server that does not serve the
48+
* `mapping` kind is quiet, while on `view` only a host with no metadata door at
49+
* all is (`classifyImportMappingsFailure` / `classifyViewsFailure`).
3850
*
3951
* ## Why the server's own words are appended untranslated
4052
*
@@ -103,7 +115,8 @@ export interface MetadataReadWarningSink {
103115
const READ_WARNING_TOAST_MS = 10_000;
104116

105117
/**
106-
* The remedy sentence, chosen by WHICH loud verdict this was.
118+
* The remedy sentence for a failed `listImportMappings`, chosen by WHICH loud
119+
* verdict this was.
107120
*
108121
* An exhaustive `switch` with a `never` check rather than a ternary, for the
109122
* reason `saveAdvisoryToast.advisoryTitle` records: a ternary answers "is it
@@ -117,8 +130,11 @@ const READ_WARNING_TOAST_MS = 10_000;
117130
* caller wraps this in a try/catch that swallows: the failure mode is therefore
118131
* "no toast", never "a toast naming the wrong remedy".
119132
*/
120-
function remedy(ev: MetadataReadWarningEvent, t: TranslateFn): string {
121-
switch (ev.reason) {
133+
function importMappingsRemedy(
134+
reason: MetadataReadWarningEvent['reason'],
135+
t: TranslateFn,
136+
): string {
137+
switch (reason) {
122138
case 'refused':
123139
return t('console.importMappingsRefused', {
124140
defaultValue:
@@ -130,14 +146,109 @@ function remedy(ev: MetadataReadWarningEvent, t: TranslateFn): string {
130146
'This list is empty because it could not be read, not because nothing is registered. Try again, and report this if it keeps happening.',
131147
});
132148
default: {
133-
const unhandled: never = ev.reason;
149+
const unhandled: never = reason;
150+
throw new Error(
151+
`metadataReadWarningToast: no remedy for reason ${JSON.stringify(unhandled)}`,
152+
);
153+
}
154+
}
155+
}
156+
157+
/**
158+
* The remedy sentence for a failed `listViews` (objectui#8151).
159+
*
160+
* Same two verdicts, same `never` discipline — a DIFFERENT second clause. The
161+
* whole point of the sentence is to deny the wrong reading the empty list
162+
* invites, and the wrong reading differs per list: "nothing is registered" is
163+
* what an absent saved-mapping selector says, while an empty `listViews` says
164+
* *this object has no saved views* — including the ones the user created
165+
* themselves, which is what makes it the sharper lie of the two.
166+
*/
167+
function savedViewsRemedy(
168+
reason: MetadataReadWarningEvent['reason'],
169+
t: TranslateFn,
170+
): string {
171+
switch (reason) {
172+
case 'refused':
173+
return t('console.savedViewsRefused', {
174+
defaultValue:
175+
'The server refused this request, so this list is empty because it could not be read — not because this object has no saved views. Sign in again, or ask an administrator for access.',
176+
});
177+
case 'unreadable':
178+
return t('console.savedViewsUnreadable', {
179+
defaultValue:
180+
'This list is empty because it could not be read, not because this object has no saved views. Try again, and report this if it keeps happening.',
181+
});
182+
default: {
183+
const unhandled: never = reason;
134184
throw new Error(
135185
`metadataReadWarningToast: no remedy for reason ${JSON.stringify(unhandled)}`,
136186
);
137187
}
138188
}
139189
}
140190

191+
/**
192+
* Which read failed decides BOTH strings (objectui#8151).
193+
*
194+
* `operation` — the adapter method — is the discriminant, not `kind`: it is
195+
* what names the list the user is standing in front of, and the two fields are
196+
* independent unions on the published event, so only one of them can be the
197+
* authority here. Exhaustive with a `never` check for the reason the per-reason
198+
* switches are: this file is the consumer objectui#7741 kept `operation` a
199+
* closed union FOR, so a third emitter must fail to compile here rather than
200+
* silently render some other read's sentence.
201+
*
202+
* ⛔ There is no shared "generic" wording either branch falls back to. A toast
203+
* that hedges about WHICH list could not be read would re-introduce, in copy,
204+
* exactly the ambiguity the event was added to remove.
205+
*/
206+
function remedy(ev: MetadataReadWarningEvent, t: TranslateFn): string {
207+
switch (ev.operation) {
208+
case 'listImportMappings':
209+
return importMappingsRemedy(ev.reason, t);
210+
case 'listViews':
211+
return savedViewsRemedy(ev.reason, t);
212+
default: {
213+
const unhandled: never = ev.operation;
214+
throw new Error(
215+
`metadataReadWarningToast: no remedy for operation ${JSON.stringify(unhandled)}`,
216+
);
217+
}
218+
}
219+
}
220+
221+
/**
222+
* The headline, chosen by the same discriminant and held to the same rule as
223+
* {@link remedy} (objectui#8151).
224+
*
225+
* Before this card the title was one hard-coded `t('console.importMappingsUnavailable')`.
226+
* That is the shape a second emitter would have turned into a runtime lie —
227+
* *"Saved import mappings for account could not be loaded"* on a failed VIEW
228+
* read — with nothing failing to compile, which is precisely what the closed
229+
* `operation` union exists to prevent.
230+
*/
231+
function title(ev: MetadataReadWarningEvent, t: TranslateFn): string {
232+
switch (ev.operation) {
233+
case 'listImportMappings':
234+
return t('console.importMappingsUnavailable', {
235+
object: ev.objectName,
236+
defaultValue: 'Saved import mappings for {{object}} could not be loaded',
237+
});
238+
case 'listViews':
239+
return t('console.savedViewsUnavailable', {
240+
object: ev.objectName,
241+
defaultValue: 'Saved views for {{object}} could not be loaded',
242+
});
243+
default: {
244+
const unhandled: never = ev.operation;
245+
throw new Error(
246+
`metadataReadWarningToast: no title for operation ${JSON.stringify(unhandled)}`,
247+
);
248+
}
249+
}
250+
}
251+
141252
/**
142253
* The server's own words about its own answer, as one line — or nothing at all
143254
* when it sent none.
@@ -160,19 +271,16 @@ function serverDetail(ev: MetadataReadWarningEvent): string | undefined {
160271
* empty result anyway.
161272
*
162273
* The title names the object, because that is the scope the empty list is about
163-
* and the wizard the user is standing in is open on exactly one object.
274+
* and the surface the user is standing in — the import wizard, or one object's
275+
* view switcher — is open on exactly one object.
164276
*/
165277
export function emitMetadataReadWarning(
166278
ev: MetadataReadWarningEvent,
167279
t: TranslateFn,
168280
sink: MetadataReadWarningSink,
169281
): void {
170-
const title = t('console.importMappingsUnavailable', {
171-
object: ev.objectName,
172-
defaultValue: 'Saved import mappings for {{object}} could not be loaded',
173-
});
174282
const detail = serverDetail(ev);
175-
sink.warning(title, {
283+
sink.warning(title(ev, t), {
176284
description: detail ? `${remedy(ev, t)}\n${detail}` : remedy(ev, t),
177285
duration: READ_WARNING_TOAST_MS,
178286
});

0 commit comments

Comments
 (0)