Skip to content

fix(test): stop CDS singleton leak reddening anonymize unit tests in CI - #3160

Merged
Thomas Jung (jung-thomas) merged 1 commit into
DEVfrom
worktree-fix-unit-test-pollution-977
Nov 21, 2026
Merged

Thomas Jung (jung-thomas) merged 1 commit into
DEVfrom
worktree-fix-unit-test-pollution-977

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

unit tests has been red on DEV since 2026-11-16. Two files fail only in the full CI suite (both pass in isolation):

  • test/admin-service.test.js → anonymizeUser blanks PII and deletes metadata
  • test/unit/anonymize-dsr-request-number.test.js (2 tests)

All fail with the same error:

no such table: DeveloperEnvironmentTabs
SELECT ID FROM DeveloperEnvironmentTabs WHERE user_ID = ?

Root cause

test/unit/srv/kg-featured-topics-job.test.js deployed a hand-picked subset (knowledge-graph/homepage-featured/tutorials/missions) — omitting db/schema.cds — to sqlite::memory:. cds.deploy().to() mutates the process-wide cds.db/cds.model singleton for the whole vitest fork worker.

On CI (maxWorkers: 4, dense file→worker packing) a later file in the same worker inherits that partial schema, which has no DeveloperEnvironmentTabs table. PR #3139 (#977) rewrote the GDPR anonymize cascade to resolve nested data subjects via an explicit SELECT ID FROM DeveloperEnvironmentTabs — which then hard-fails on the missing table. (Pre-#977 the cascade issued only a bare DELETE, so the leak was latent.)

Locally (unbounded workers) the files land in separate fresh workers, so it's green — matching passes in isolation, red in full suite and CI-only.

Fix

Deploy all of db/ in the job test's beforeAll instead of a subset, restoring every table + @PersonalData annotation into the shared singleton. The job under test only needs an empty DB, so the full model is harmless.

Verification

  • kg-featured-topics-job.test.js passes standalone and alongside both anonymize files (1+39+2 green locally).
  • Note: the cross-file leak itself is only reproducible under CI fork-packing; local runs can't force two files into one worker. Relying on this PR's CI run against the full suite as the real confirmation.

🤖 Generated with Claude Code

…ss-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.
@jung-thomas
Thomas Jung (jung-thomas) merged commit 5f63017 into DEV Nov 21, 2026
3 of 4 checks passed
@jung-thomas
Thomas Jung (jung-thomas) deleted the worktree-fix-unit-test-pollution-977 branch November 21, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant