From 3fab2676cb6b8637d86ad9da65b3853837cff964 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:32:13 +0000 Subject: [PATCH 1/2] fix(app-shell): a record page asks no definition a member is refused or nothing draws The record route asked the targets of hidden system lookups (organization_id, owning_business_unit_id) by name, and the record view asked the reaction object's presence of a caller whose grants hold no read on it; the metadata door answers both as absent for such a caller, so a member logged 404s on every record page. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- .../__tests__/appObjectScope-12811.test.tsx | 50 ++++++++++++-- .../app-shell/src/console/appObjectScope.ts | 14 +++- .../RecordDetailView.feedGrant-12082.test.tsx | 65 +++++++++++++++++++ .../app-shell/src/views/RecordDetailView.tsx | 22 +++++-- 4 files changed, 139 insertions(+), 12 deletions(-) diff --git a/ui/packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx b/ui/packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx index e5a3f7e5ee4..495b0ae6daf 100644 --- a/ui/packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx +++ b/ui/packages/app-shell/src/console/__tests__/appObjectScope-12811.test.tsx @@ -37,7 +37,7 @@ const OBJECTS = [ { name: 'sys_user', _packageId: 'plugin.auth', fields: {} }, ]; -function makeAdapter(calls: string[], apps: unknown[]) { +function makeAdapter(calls: string[], apps: unknown[], objects: readonly { name: string }[] = OBJECTS) { return { clearCache: vi.fn(), invalidateCache: vi.fn(), @@ -53,13 +53,13 @@ function makeAdapter(calls: string[], apps: unknown[]) { meta: { getItems: (type: string, options?: { packageId?: string }) => { calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type); - const all = type === 'object' ? OBJECTS : type === 'app' ? apps : []; + const all = type === 'object' ? objects : type === 'app' ? apps : []; const items = options?.packageId ? all.filter((o: any) => o._packageId === options.packageId) : all; return Promise.resolve({ type, items: structuredClone(items) }); }, getItem: (type: string, name: string) => { calls.push(`${type}/${name}`); - const item = (type === 'object' ? OBJECTS : []).find((o) => o.name === name); + const item = (type === 'object' ? objects : []).find((o) => o.name === name); return item ? Promise.resolve({ item: structuredClone(item) }) : Promise.reject(new Error('404')); }, }, @@ -72,12 +72,12 @@ function Prefetch() { return null; } -function mount(url: string, apps: unknown[]): string[] { +function mount(url: string, apps: unknown[], objects?: readonly { name: string }[]): string[] { // Each mount reads its own app list, not the one a previous mount cached. sessionStorage.clear(); const calls: string[] = []; render( - + @@ -251,3 +251,43 @@ describe('objectstack#29551 — a packaged app asks its lookup targets without v expect(scope()).toBe('crm_account[crm_account.all],crm_contact[crm_contact.all]'); }); }); + +describe('objectstack#33343 — a hidden lookup asks no definition of its target', () => { + /** + * The route object carries the injected system scope anchors as the server + * serves them: `organization_id` and `owning_business_unit_id`, hidden + * lookups to `sys_organization` and `sys_business_unit`. No cell draws a + * hidden field, and the metadata door answers a definition the caller may + * not read as absent, so a member was answered 404 on every route. + */ + const withAnchors = (hidden: boolean) => [ + { + name: 'crm_account', + _packageId: CRM, + fields: { + owner: { type: 'lookup', reference: 'sys_user' }, + organization_id: { type: 'lookup', reference: 'sys_organization', hidden, system: true }, + owning_business_unit_id: { type: 'lookup', reference: 'sys_business_unit', hidden, system: true }, + }, + }, + { name: 'sys_user', _packageId: 'plugin.auth', fields: {} }, + { name: 'sys_organization', _packageId: 'plugin.auth', fields: {} }, + { name: 'sys_business_unit', _packageId: 'plugin.security', fields: {} }, + ]; + + it('the route asks its drawn lookup target by name, and never the targets of its hidden lookups', async () => { + const calls = mount('/apps/crm/crm_account', APPS, withAnchors(true)); + await waitFor(() => expect(calls).toContain('object/sys_user')); + await new Promise((resolve) => setTimeout(resolve, 50)); + expect(objectCalls(calls)).toEqual([`object?package=${CRM}`, 'object/sys_user']); + }); + + it('CONTROL: the same lookups drawn ask every target by name', async () => { + const calls = mount('/apps/crm/crm_account', APPS, withAnchors(false)); + await waitFor(() => expect(calls).toContain('object/sys_business_unit')); + await new Promise((resolve) => setTimeout(resolve, 50)); + expect([...objectCalls(calls)].sort()).toEqual( + [`object?package=${CRM}`, 'object/sys_business_unit', 'object/sys_organization', 'object/sys_user'].sort(), + ); + }); +}); diff --git a/ui/packages/app-shell/src/console/appObjectScope.ts b/ui/packages/app-shell/src/console/appObjectScope.ts index 9184fa27207..bf21d319e98 100644 --- a/ui/packages/app-shell/src/console/appObjectScope.ts +++ b/ui/packages/app-shell/src/console/appObjectScope.ts @@ -430,12 +430,24 @@ function hasRecordFormOverlay(search: string): boolean { return sp.has(RECORD_FORM_PARAM) || sp.has(RECORD_FORM_OBJECT_PARAM); } -/** The objects an object's lookup and master-detail fields point at. */ +/** + * The objects an object's drawn lookup and master-detail fields point at. + * + * A target is read for the cell that links and names it, so a field declared + * `hidden: true` asks for none: no surface this scope serves draws it. That + * includes the injected system scope anchors (`organization_id` and + * `owning_business_unit_id`), which point at `sys_organization` and + * `sys_business_unit` from every object; asking their definitions read nothing + * a page draws, and for a caller the object read check refuses, the metadata + * door answers that definition as absent (ADR-0106 as amended by ruling record + * 6787890900), so the read answered 404 on every route of every object. + */ function lookupTargetNames(def: any): string[] { const fields = def?.fields; const defs: any[] = Array.isArray(fields) ? fields : Object.values((fields ?? {}) as Record); const out = new Set(); for (const field of defs) { + if (field?.hidden === true) continue; if ((field?.type === 'lookup' || field?.type === 'master_detail') && typeof field.reference === 'string' && field.reference) { out.add(field.reference); } diff --git a/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx index 13e6373aa47..251eb6f60ad 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx @@ -426,3 +426,68 @@ describe('on the column store the reaction control reads feedReactionColumn: upd expect(!!addReaction(view)).toBe(offered); }); }); + +/** + * Which store the chatter uses is asked of the object registry only by a + * caller who may read `sys_comment_reaction` (objectstack#33343). The metadata + * door serves an object's definition only to a caller its read check admits, + * so a caller whose grants hold no read on the object was answered 404 on every + * record page; that answer took the column store. Here the registry is the + * by-name scope reader, which records each name the page asks. + */ +describe('the reaction store is asked of the registry only by a caller who may read sys_comment_reaction (objectstack#33343)', () => { + /** Mounts the page over a by-name registry; returns the object names it was asked. */ + async function mountAsking(perms: MePermissionsResponse | null, registry: unknown[], dataSource = makeDataSource()) { + const asked: string[] = []; + const pages = [PAGE]; + const readObjectScope = (scope: { packageId?: string; names?: readonly string[] }) => { + asked.push(...(scope.names ?? []).filter((name) => typeof name === 'string' && name !== '')); + const served = scope.names + ? registry.filter((o) => scope.names!.includes((o as { name: string }).name)) + : registry; + return { objects: served, served, missing: [], settled: true, failed: [], refused: {}, answers: {}, views: [] }; + }; + const metadata = { + ...metadataFor(registry), + readObjectScope, + getTypeStatus: (type: string) => (type === 'object' ? 'idle' : 'ready'), + ensureType: async () => pages, + } as any; + const page = ( + + + {}} + objectNameOverride={OBJECT_NAME} + recordIdOverride={RECORD_ID} + embedded + /> + + + ); + const view = render(perms ? {page} : page); + await within(view.container).findByText(COMMENT_BODY); + await act(async () => {}); + const reactionReads = dataSource.find.mock.calls.filter(([objectName]: [string]) => objectName === REACTION); + return { asked, reactionReads }; + } + + it('a caller whose grants hold no read on sys_comment_reaction is not asked about it, and takes the column store its absence took', async () => { + const { asked, reactionReads } = await mountAsking(answer({ [COMMENT]: SHAPE.full }), REGISTRY.column); + expect(asked).not.toContain(REACTION); + expect(reactionReads).toEqual([]); + }); + + it('CONTROL — a caller who may read it asks the registry, and the records store reads its rows', async () => { + const { asked, reactionReads } = await mountAsking(answer({ [COMMENT]: SHAPE.full, [REACTION]: SHAPE.readOnly }), REGISTRY.records); + expect(asked).toContain(REACTION); + expect(reactionReads).toHaveLength(1); + }); + + it('CONTROL — with no permission provider every grant reads open: the registry is asked, as before', async () => { + const { asked } = await mountAsking(null, REGISTRY.records); + expect(asked).toContain(REACTION); + }); +}); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index eb89f06eef9..b688dab3b38 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -3176,12 +3176,22 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // path, and every uncertain answer takes the records path. `null` until the // registry has answered, and the feed read waits for it: comments and their // reactions are read as one answer. - const reactionPresence = useObjectPresence(COMMENT_REACTION_OBJECT); - const reactionStore: 'records' | 'column' | null = !reactionPresence.settled - ? null - : reactionPresence.presence === 'absent' - ? 'column' - : 'records'; + // + // A caller whose loaded grants hold no read on the object is not asked about + // it: the metadata door serves an object's definition only to a caller its + // read check admits (ADR-0106 as amended by ruling record 6787890900), and + // the object declares no `schemaReadDelegate`, so that read could only + // answer absent (a 404 on every record page). It takes the path that answer + // takes. With no permission provider every grant reads open, as before. + const reactionReadRefused = perms.isLoaded && !perms.can(COMMENT_REACTION_OBJECT, 'read'); + const reactionPresence = useObjectPresence(reactionReadRefused ? '' : COMMENT_REACTION_OBJECT); + const reactionStore: 'records' | 'column' | null = reactionReadRefused + ? 'column' + : !reactionPresence.settled + ? null + : reactionPresence.presence === 'absent' + ? 'column' + : 'records'; /** * The signed-in user's own reaction rows, per comment (`[thread, comment]`) * and emoji: the row id a click that takes the reaction back deletes. Filled From e7b95effb8c2b09602797d01e200d5ccde0fb046 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 22:39:15 +0000 Subject: [PATCH 2/2] chore(changeset): record page member meta reads Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- .changeset/33343-record-page-member-meta-404.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .changeset/33343-record-page-member-meta-404.md diff --git a/.changeset/33343-record-page-member-meta-404.md b/.changeset/33343-record-page-member-meta-404.md new file mode 100644 index 00000000000..ac29762165f --- /dev/null +++ b/.changeset/33343-record-page-member-meta-404.md @@ -0,0 +1,15 @@ +--- +'@object-ui/app-shell': patch +--- + +fix(app-shell): a member's record page asks no object definition the metadata door would answer as absent + +Clause-②: no +Metadata-protocol: none + +A member (a caller with no administrator grant) opening a record page logged two `404`s, `GET /api/v1/meta/object/sys_business_unit` and `GET /api/v1/meta/object/sys_comment_reaction`. The metadata door serves an object's definition only to a caller its read check admits, and answers any other caller as if the object did not exist; the stock member grants hold no read on either object, so both answers are correct, and the page should not have asked. + +- The record and list routes ask the definitions of their object's lookup targets, for the cells that link and name them. They no longer ask the target of a field declared `hidden: true`, which no cell draws. That includes the system scope fields the platform adds to an object (`organization_id` and `owning_business_unit_id`), which point at `sys_organization` and `sys_business_unit`; those two reads are gone for every caller. +- The record page asks whether the deployment has `sys_comment_reaction` to choose where reactions are stored. A caller whose loaded grants hold no read on that object is no longer asked: it takes the reactions path the absent answer took before. With no permission provider mounted, the page asks as before. + +Nothing a member or an administrator sees on the page changes, and no server answer changes.