From a31d02b4904ba27a1eefbd153fc559e461798efa Mon Sep 17 00:00:00 2001 From: Thomas Jung Date: Sat, 21 Nov 2026 09:18:30 -0500 Subject: [PATCH] fix(test): deploy full db model in kg-featured-topics-job to stop cross-file CDS singleton leak The test deployed a hand-picked subset omitting db/schema.cds to the shared sqlite::memory: DB. cds.deploy().to() mutates the process-wide cds.db/cds.model singleton for the whole vitest fork worker, so on CI (maxWorkers:4, dense file-to-worker packing) a later file in the same worker inherited a schema missing DeveloperEnvironmentTabs. #977 made the GDPR anonymize cascade's nested-subject resolution issue a SELECT ID FROM DeveloperEnvironmentTabs, which then hard-failed with 'no such table', reddening admin-service.test.js and anonymize-dsr-request-number.test.js in the full suite (green in isolation). Deploying all of db/ restores every table + @PersonalData annotation into the singleton; the job under test only needs an empty DB. --- test/unit/srv/kg-featured-topics-job.test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/unit/srv/kg-featured-topics-job.test.js b/test/unit/srv/kg-featured-topics-job.test.js index 3589dcbba..c862994f9 100644 --- a/test/unit/srv/kg-featured-topics-job.test.js +++ b/test/unit/srv/kg-featured-topics-job.test.js @@ -3,7 +3,16 @@ import cds from '@sap/cds'; describe('kg-featured-topics-job', () => { beforeAll(async () => { - await cds.deploy(['db/knowledge-graph.cds','db/homepage-featured.cds','db/tutorials.cds','db/missions.cds']).to('sqlite::memory:'); + // Deploy the FULL db model, not a hand-picked subset. cds.deploy().to() + // mutates the process-level cds.db/cds.model singleton for the whole vitest + // fork worker; a partial set leaked a schema missing db/schema.cds tables + // (e.g. DeveloperEnvironmentTabs) into later files in the same CI worker, + // crashing the GDPR anonymize cascade's nested-subject SELECT with + // "no such table: DeveloperEnvironmentTabs" (#977 made that SELECT fatal). + // Deploying all of db/ (not srv/) restores every table + @PersonalData + // annotation into the singleton without loading service handlers; the job + // under test only needs an empty DB, so the full model is harmless. + await cds.deploy(['db']).to('sqlite::memory:'); }); it('runs without throwing when inputs are empty', async () => {