From 6ef07e8ca264f3b6c8c201abb6df00017825495c Mon Sep 17 00:00:00 2001 From: Thomas Jung Date: Sat, 21 Nov 2026 11:04:59 -0500 Subject: [PATCH] fix(#977): qualify DeveloperEnvironmentTabs via-name in anonymize cascade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The data-subject resolver returned the nested-marker `via: 'DeveloperEnvironmentTabs'` (bare name). The GDPR anonymize actions are bound to the served AdminService, so the cascade's `SELECT.from('DeveloperEnvironmentTabs')` resolved to the AdminService *projection* in that request context and CAP emitted literal `SELECT ID FROM DeveloperEnvironmentTabs` — a table that does not exist (the physical table is com_sap_developers_ims_DeveloperEnvironmentTabs). Result: 500 'no such table: DeveloperEnvironmentTabs' in anonymizeUser/anonymizeByDsrRequest, reddening the unit suite on CI (green in isolation / direct-db unit context, where the bare name resolves to the db entity). Qualify `via` to the full CDS name so it always resolves to the db-layer entity and the correct namespaced table, in both the served and direct-db contexts. Update the two tests that asserted the old bare marker/SQL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- srv/lib/data-subject-resolver.js | 13 +++++++++++-- .../unit/anonymization-cascade-authorid-gap.test.js | 6 +++++- test/unit/data-subject-resolver.test.js | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/srv/lib/data-subject-resolver.js b/srv/lib/data-subject-resolver.js index 4959ab919..77838de87 100644 --- a/srv/lib/data-subject-resolver.js +++ b/srv/lib/data-subject-resolver.js @@ -15,7 +15,7 @@ * The resolver cannot produce tab IDs without a DB query, so it returns a * nested marker instead of resolved values: * - * { column: 'tab_ID', values: null, nested: true, via: 'DeveloperEnvironmentTabs' } + * { column: 'tab_ID', values: null, nested: true, via: 'com.sap.developers.ims.DeveloperEnvironmentTabs' } * * Task-4 (export handler) and Task-5 (anonymization cascade fix) MUST check * for `result.nested === true` and: @@ -75,12 +75,21 @@ export async function resolveSubjectKeys(user, planEntry) { // DeveloperEnvironmentLinks — linked via parent DeveloperEnvironmentTabs (tab_ID) // Cannot resolve without a DB query; return a nested marker for the caller to handle. + // + // `via` MUST be the fully-qualified CDS name, not the bare "DeveloperEnvironmentTabs". + // The cascade runs inside the AdminService request context (the GDPR actions are + // bound to that served service), where a bare "DeveloperEnvironmentTabs" resolves to + // the AdminService *projection* and CAP emits literal `SELECT ID FROM + // DeveloperEnvironmentTabs` — a table that does not exist (the physical table is + // `com_sap_developers_ims_DeveloperEnvironmentTabs`), producing a 500 + // "no such table: DeveloperEnvironmentTabs". Qualifying the name forces resolution + // to the db-layer entity and the correct namespaced table. if (dataSubjectField === 'tab_ID') { return { column: 'tab_ID', values: null, nested: true, - via: 'DeveloperEnvironmentTabs' + via: 'com.sap.developers.ims.DeveloperEnvironmentTabs' }; } diff --git a/test/unit/anonymization-cascade-authorid-gap.test.js b/test/unit/anonymization-cascade-authorid-gap.test.js index 55900e14d..1290e4b25 100644 --- a/test/unit/anonymization-cascade-authorid-gap.test.js +++ b/test/unit/anonymization-cascade-authorid-gap.test.js @@ -199,8 +199,12 @@ describe('anonymization-cascade: AuthorAiRequests authorId gap', () => { // never runs AND this intermediate SELECT never runs either. // If `resolved.via` were changed to a wrong entity, a different SELECT // would appear instead — both cases cause this assertion to fail. + // capturedRuns stores JSON.stringify(cqn), so it holds the fully-qualified + // CDS name `com.sap.developers.ims.DeveloperEnvironmentTabs` (dotted) — NOT + // the bare "DeveloperEnvironmentTabs", which would collide with the + // AdminService projection and 500 through the served context (#977 CI bug). const nestedSelectFired = capturedRuns.some( - s => s.includes('"DeveloperEnvironmentTabs"') && s.includes('user_ID') && s.includes(userId) + s => s.includes('com.sap.developers.ims.DeveloperEnvironmentTabs') && s.includes('user_ID') && s.includes(userId) ); expect(nestedSelectFired).toBe(true); diff --git a/test/unit/data-subject-resolver.test.js b/test/unit/data-subject-resolver.test.js index 35b28aeb1..27249efd6 100644 --- a/test/unit/data-subject-resolver.test.js +++ b/test/unit/data-subject-resolver.test.js @@ -109,7 +109,7 @@ describe('resolveSubjectKeys', () => { expect(result).not.toBeNull(); expect(result.column).toBe('tab_ID'); expect(result.nested).toBe(true); - expect(result.via).toBe('DeveloperEnvironmentTabs'); + expect(result.via).toBe('com.sap.developers.ims.DeveloperEnvironmentTabs'); // values should be null (caller must resolve the parent Tabs first) expect(result.values).toBeNull(); });