Skip to content

fix(#977): reserve /admin/data-privacy backend route (AdminService was swallowing it) - #3147

Merged
jung-thomas merged 1 commit into
DEVfrom
fix/977-data-privacy-backend-route
Nov 17, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
fix/977-data-privacy-backend-route

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

DataPrivacyService (/admin/data-privacy) 404s with Invalid resource path AdminService.data-privacy. DataPrivacyService is defined at @(path:'/admin/data-privacy'), but AdminService's OData adapter mounts at /admin and intercepts the nested /admin/data-privacy/* path first.

The approuter route added in #3142 was necessary but not sufficient — the backend still needs a late-bound router reservation or the request never reaches DataPrivacyService.

Fix

Single-file change to srv/server.js, mirroring the existing AnalyticsService (/admin/analytics) late-bound reservation exactly:

  1. Declare a stub dataPrivacyOdataRouter (503 during boot).
  2. Reserve /admin/data-privacy/* in the same bootstrap/pre-serve block that reserves /admin/analytics, BEFORE CAP mounts AdminService, so express routes the longer prefix to the stub first.
  3. Wire the stub to the real DataPrivacyService OData adapter in the cds.on('served') handler, wrapped with the same contextMw + authMw middlewares, with the same CDS-9/CDS-10 adapter-shape handling.

No .cds or approuter/xs-app.json changes.

Verification

  • npx cds build --production exits 0.
  • test/unit/data-privacy-export.test.js + test/unit/data-privacy-service-metadata.test.js pass (13 tests). (Unit tests run the service in-process and do not exercise server.js routing; they confirm no regression.)

…OData adapter does not swallow it

DataPrivacyService is defined at @(path:'/admin/data-privacy'). AdminService's
OData adapter mounts at /admin and intercepts the nested /admin/data-privacy/*
path first, returning "Invalid resource path AdminService.data-privacy" (404).

This mirrors the existing AnalyticsService (/admin/analytics) late-bound
reservation in srv/server.js: declare a stub router, reserve the longer
/admin/data-privacy/* prefix in the bootstrap/pre-serve block BEFORE CAP mounts
AdminService, then wire the stub to the real DataPrivacyService OData adapter in
the cds.on('served') handler (wrapped with the same context + auth middlewares).

The approuter route added in #3142 was necessary but not sufficient on its own:
the backend still needs this reservation or the request never reaches
DataPrivacyService.
@jung-thomas
jung-thomas merged commit 2b6a30d into DEV Nov 17, 2026
4 of 5 checks passed
@jung-thomas
jung-thomas deleted the fix/977-data-privacy-backend-route branch November 17, 2026 03:45
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