Skip to content

release 1.44.4: SAGE IAS backend promotion (DEV→main) - #3163

Merged
Thomas Jung (jung-thomas) merged 79 commits into
mainfrom
release/dev-to-main-1.44.4
Nov 21, 2026
Merged

Thomas Jung (jung-thomas) merged 79 commits into
mainfrom
release/dev-to-main-1.44.4

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Release 1.44.4 — DEV→main promotion

Promotes origin/DEV (2886262) to main. Version bump .deploy/mta.yaml 1.44.3 → 1.44.4 (patch; deploy source of truth).

Headline: SAGE isolated IAS-authenticated backend (srv-sage)

Removes the embedded PROD XSUAA client secret from the SAGE VS Code extension (the original security finding) and replaces it with a dedicated IAS public-client PKCE flow calling an isolated srv-sage CAP module. Verified end-to-end on DEV — IMS sign-in, My Tutorials, and tutorial preview all render live:

Also carried (~73 other merged DEV PRs)

Data-privacy backend routes (#3139-3147), concept render/order fixes, navigator search (#3112/#3156), render-concepts OOM (#3154), snippet CI gate (#3155), and others merged to DEV since 1.44.3.

Deploy plan (post-merge, each separately authorized)

  1. Main platform MTA → PROD (blue-green, from fresh origin/main)
  2. srv-sage MTA → PROD (deploy/mta-sage-prod.mtaext, from fresh origin/main)
  3. Stable SAGE 2.0.5 VSIX with PROD config

Mirrors the #3134 release/dev-to-main-1.44.3 pattern. Full platform release — affects all of tutorials-ims, not only SAGE.

…ollup regression test (#3120)

- Remove the `if (!priorTutorialRow) reject(409)` gate in `doResetTutorialProgress`
  (srv/developer-service.js); reset now proceeds whenever `liveRows.length > 0`.
- `previousAttemptCompletedAt` is `null` for a partial reset (already nullable).
- Invert the two #2446 unit tests (now assert 200, rows superseded, fresh attempt).
- Add replacement regression guard: seeds tutorial → GROUP via GroupPathItems, seeds
  GROUP TaskRecord as COMPLETED, partial-resets the tutorial, asserts getProgress
  returns completedSteps:[] AND the GROUP TaskRecord is NOT COMPLETED after the
  rollUpParentsForCompletion(allowDowngrade:true) call.
…w-ux

fix(validation): clearer Yellow AI-grade UX + mid-tutorial reset (#3120)
Approved design: deliver CAP's native NOT VALIDATED draft cascade
constraints through the hdbmigrationtable build, re-enable
draft_admin_integrity + draft_orphan_cleanup + deleteStrategy:dad,
with a dad handler-firing audit + HANA-level reconcile test.

Spike findings: constraints are CAP-native (46, NOT VALIDATED), the
real blocker was the to.hana/hdbmigrationtable build path (not HDI
make-graph or hand-authoring).
…ntable build

Pin @sap/cds-compiler to 7.2.1 via package.json overrides. The project's
hoisted @sap/cds-compiler was stuck at 7.0.1 (lockfile dedup artifact), which
predates createDraftAdminDataConstraints; so cds build --production emitted 0
draft cascade constraints even with draft_admin_integrity on. Compiler 7.2.1
(bundled under cds-dk, now pinned at root) emits all 46
*_drafts_DraftAdministrativeData.hdbconstraint files (ON DELETE CASCADE,
NOT VALIDATED). draft_admin_integrity stays OFF in both fiori blocks; the
runtime flip is a later task.
Save/restore process.env.CDS_ENV around cds.load + compiler.to.hdi in a
finally block so the production-profile flag does not leak into co-running
unit tests that share the same vitest worker process.
…-pass resolvedMap, pass definitions param

- LOG.warn when _selectRows finds a declared personalField not in entity elements (GDPR safety, fix 1)
- Build resolvedMap in pre-scan and reuse in main loop to avoid double resolveSubjectKeys calls (fix 2)
- Resolve definitions once in _handleExport and pass as parameter to _selectRows (fix 3)
- Add unit test asserting LOG.warn fires AND row still exports with real columns (fix 1 test)
…t bodies hash stably (#3135)

The render-concepts publish phase flagged ~all 10,615 concepts as changed on
every prod rebuild, forcing a full ~90s synchronous re-render that OOMed the 2G
instance / starved the 10s CF liveness probe -> instance crash -> HTTP 502 ->
rebuild failure (#3135).

Root cause: the teaches/requires/relatedTo/requiredBy reads in
published-concepts-query.js had no ORDER BY. On HANA, row order is
non-deterministic without ORDER BY, so each rebuild rendered the concept
relationship tile lists in a different order -> body HTML changed -> contentHash
changed -> every concept looked changed. #3095's cap-at-24 compounded it.

Fix: order each relationship read by the related item's slug
(tutorial.slug / target.slug / source.slug). Grouping and the template already
preserve array order, so stable SQL order makes concept bodies hash identically
across runs and the per-concept delta skip works.

SQLite (unit tests) preserves insertion order and never reproduced this; the new
test inserts edges in reverse-sorted order to prove the ordering holds.
…tegy

Flips the three CAP 10.2 Optimized Draft Deletion flags in both base and
[development] profiles:
- cds.fiori.draft_admin_integrity: true  (emits 46 NOT VALIDATED draft
  cascade constraints at build time; requires the 7.2.1 compiler pin)
- cds.fiori.draft_orphan_cleanup: true   (background orphan sweep)
- cds.drafts.deleteStrategy: dad          (single-cascade draft deletion)

Generation of the cascade constraints is gated on draft_admin_integrity
being true, so constraints + runtime behavior ship together in one build.
Verified: production build emits 46/46 NOT VALIDATED constraints.
DEV HANA deploy + preflight + dad hook audit pending (Tasks 3-6).
…st KG reads (#3135)

Final-review completeness fix. contentHash = sha256(body) and body renders eight
phase-4 lists (learningJourneys/blogPosts/discoveryMissions/videos/apiDocs/samples/
helpDocs/communityEvents) in addition to the three KG relationship lists. Those also
drive hash churn:

- learningJourneys had NO ordering (same defect class as the KG reads) -> add
  .orderBy('journey.slug').
- discoveryMissions/videos/apiDocs/samples/helpDocs ordered by non-unique keys with no
  unique tiebreaker (ties reorder on HANA) -> append unique slug as final sort key.
- blogPosts/communityEvents Node-side sorts had no tiebreaker -> add slug localeCompare.

Without this the per-concept delta skip would still miss on any concept with multi-item
journeys/videos/missions, and the two-rebuild verification would show residual churn.
#2993: re-enable draft_admin_integrity via native NOT VALIDATED cascade constraints
…-order

fix(concepts): deterministic ordering of concept-body lists to stop full-render churn (#3135)
- Add DataPrivacyService rows to testing-endpoints.md (path /admin/data-privacy,
  auth XSUAA + Admin, exportDataSubject(userId) function)
- srv-qa cp-list audit: check-srv-qa-cp-list.ts reports OK — 0 transitive
  srv/* dependencies from srv-qa entry points; new files (data-subject-resolver.js,
  data-privacy-service.js) are not reachable from srv-qa/server.js via static
  import analysis. No mta.yaml change needed.
Part A — Action path confirmed (imsApiClient.ts analysis):
  SAGE extension POSTs bare paths: /author/isSlugAvailable (line 159),
  /author/reviewTutorial (line 188), /author/snoozeTutorial (line 195).
  CAP OData4 accepts both qualified and bare unbound-action paths — no @path
  alias needed. author-sage-service.cds updated with confirmed analysis in
  comments (removes provisional "task 5 confirms" note).

Part B — Preview renderer ported from srv-qa to srv-sage:
  - srv-sage/preview-renderer.js: adapted from srv-qa/preview-renderer.js;
    imports from ./lib/parsers.bundle.mjs (workspace-first, bundle fallback)
  - srv-sage/preview-semaphore.js: copied from srv-qa/preview-semaphore.js
  - srv-sage/server.js: adds POST /preview/render with IAS authenticated-user
    gate (req.user guard, fail-closed); no XSUAA scope check (IAS tokens carry
    no XSUAA scopes)
  - srv-sage/package.json: adds hugo-extended 0.147.8 (same pin as srv-qa)
  - package.json: prebuild:parsers-bundle now also builds srv-sage/lib/parsers.bundle.mjs
  - scripts/bundle-shared.cjs: comment updated; parsers.bundle built by
    prebuild:parsers-bundle (from scripts/parsers/index.ts), not here
  - srv-sage/lib/parsers.bundle.mjs: generated artifact (1.2 MB esbuild output)

Verified: cds compile clean; parsers bundle smoke test passes (composeTutorial,
renderHugoFrontmatter, normalizeVideo all present and functional).
…r import

Three review fixes on Task 5 output:

1. [Important] srv-sage/server.js — hoist IAS auth guard before express.json()
   so unauthenticated callers never trigger 50 MB body buffering. Guard is now
   a dedicated middleware in position 1 of the route chain (before body parse),
   matching srv-qa's pattern of placing requireAuthorScope before the parser.
   req.user?.id absent → 401 immediately, fail-closed.

2. [Minor] srv-sage/preview-renderer.js — fix stale header comment: was
   './lib/_shared/parsers.bundle.mjs', corrected to './lib/parsers.bundle.mjs'
   (the actual flat path used by both the import and prebuild:parsers-bundle).

3. [Minor] srv-sage/preview-renderer.js — replace dead try/catch workspace-
   first import with a direct static import of ./lib/parsers.bundle.mjs,
   matching srv-qa's pattern. @tutorials/parsers doesn't exist in packages/,
   so the try always threw; the static import is cleaner and honest.
New standalone MTA (tutorials-sage, ID tutorials-sage) packaging the
srv-sage module as tutorials-srv-sage on CF. Mirrors the mta-mcp.yaml
existing-service adoption pattern: adopts tutorials-hana, tutorials-xsuaa
(DEV) / xsuaa-imsprod (PROD via mtaext), and tutorials-sage-identity
(dedicated IAS public-PKCE instance provisioned per sage-ias-setup.md).

Before-all: npm install + bundle-shared.cjs (core.bundle.mjs) +
prebuild:parsers-bundle (parsers.bundle.mjs) + cds build --production.
Removes @tutorials/core from gen/srv-sage/package.json post-build to
prevent mbt workspace-symlink packaging failure (mirrors mta-mcp.yaml).

Adds deploy/mta-sage-{dev,prod}.mtaext:
- dev: no-op (tutorials-xsuaa is correct in dev space)
- prod: overrides tutorials-xsuaa → service-name: xsuaa-imsprod

Updates docs/developers/operations/mta-deployment.md: architecture
diagram updated to three MTAs; new SAGE MTA section; Key Files table.

Verified: mbt build -f mta-sage.yaml -t mta_archives succeeds; mtar
(tutorials-sage_1.0.0.mtar, 5.5MB) contains srv/lib/_shared/core.bundle.mjs
and srv/lib/parsers.bundle.mjs.
Generated build artifact (rebuilt by mta-sage.yaml before-all via
prebuild:parsers-bundle). srv-qa gitignores its equivalent; srv-sage was
mistakenly committing it — shipping a 1.2MB generated file into git and
tripping GitHub secret-scanning on a high-entropy string inside
sanitize-html's generated entity-decode trie (decodeTrieDict compressed
lookup data — a false positive, not a credential). Gitignored to match srv-qa.
feat(srv-sage): isolated IAS backend for SAGE auth (Part A — backend + MTA)
PR #3150 added docs/developers/operations/sage-ias-setup.md without a
sidebar entry, so check-docs-sidebar.cjs failed the Deploy Docs to
GitHub Pages workflow (exit 1, unregistered page).

Co-authored-by: Thomas Jung <thomas.jung@sap.com>
fix(docs): register sage-ias-setup in VitePress sidebar
…ication

Two defects found while running the runbook live (DEV+PROD provisioning
2026-11-20):

1. grant-types was [authorization_code_pkce_s256, refresh_token] — the IAS
   broker 400s this: 'Refresh flow can only be set, if at least one grant
   type is set from: [authorizationCode,...]'. Fixed to include the base
   authorization_code grant (matches the working tutorials-identity config).

2. Step 6 verified public-client via the tenant .well-known
   token_endpoint_auth_methods_supported=none — wrong: tenant metadata never
   shows 'none' for a per-app public client. Replaced with the authoritative
   per-instance 'cf service --params' oauth2-configuration check.

Both tutorials-sage-identity instances (DEV clientid 3f4e1887…, PROD
34001456…) are provisioned + verified public-client:true on tenant
atxgsg7zi.
…t-types

fix(docs): correct SAGE IAS runbook grant-types + public-client verification
…workflows

The scheduled content-drift-check started failing with a false 'drift'
alarm: its Fetch-tutorials step hard-aborts before verify.log is written.
Root cause is not content drift — it is a CI gate gap.

fetchSnippets() (scripts/parsers/github.ts) is gated by SNIPPETS_ENABLED_REPOS
and returns an empty map when unset, so every repo-snippet `::include`
throws directive/include-not-found at compose time (e.g.
directive-content-reuse's ::include[btp-trial-setup], whose snippet file
DOES exist at meta-tutorials/_snippets/btp-trial-setup.md). Commit 38c1311
made compose errors fatal but only set the var on rebuild-content.yml,
leaving the other three composing workflows to break loudly.

Mirror rebuild-content.yml's gate onto:
- content-drift-check.yml (the failing scheduled job)
- rebuild-content-qa.yml
- deploy.yml (prod prefetch, QA prefetch, and the Build-MTA env block —
  mta.yaml's before-all re-runs the composing fetch during mbt build)

Additions only; no behavior change beyond enabling snippet resolution.
…e-ci

fix(ci): set SNIPPETS_ENABLED_REPOS on all composing fetch-tutorials workflows
…concepts-oom

fix(publish): harden render-concepts full pass against OOM / liveness crash (#3138)
/preview/render is registered in cds.on('bootstrap') on the raw Express
app, OUTSIDE CAP's service-level auth middleware. CAP only populates
req.user / cds.context.user for CAP service handlers (AuthorSageService),
NOT for bootstrap-mounted routes. So the guard 'if (!req.user?.id) ->
401' rejected EVERY preview request even with a valid IAS bearer —
author ops worked (CAP services) but preview returned
401 {error:unauthenticated}.

Fix: add previewIasAuthMiddleware (srv-sage/preview-auth-mw.js), a
route-scoped IAS bearer validator ported from the proven
srv/lib/a2a/ias-auth-mw.js pattern (CAP ias-auth factory + XSUAA
fallback), adjusted for srv-sage bindings (IAS tutorials-sage-identity;
XSUAA by label 'xsuaa', dev 'tutorials-xsuaa' / prod 'xsuaa-imsprod').
It populates cds.context.user and fails closed (401) on anonymous or
when the IAS binding is unavailable. Runs before express.json() so an
unauthenticated 50 MB body is never buffered.

Verified: cds build --production emits gen/srv-sage/srv/preview-auth-mw.js.
Closes the integration-smoke TODO the route left itself; needs DEV
redeploy + live preview retest.
…auth

fix(srv-sage): validate IAS bearer on /preview/render (was always 401)
…earch-count-guard

fix(search): mission search count-guard + pinned filters (#3112, supersedes #3123)
…w/render

Follow-up to #3157. That PR wired previewIasAuthMiddleware but it still
401'd a VALID IAS token. Root cause (from deployed srv-sage logs):

  auth: Error while authenticating user: Cannot set properties of
  undefined (setting 'user')  at ias_auth (.../auth/ias-auth.js:72)

CAP's ias_auth does `cds.context.user = ...` at ias-auth.js:72. On a CAP
service route that succeeds because CAP's own context middleware
(@sap/cds/lib/srv/middlewares/cds-context.js) ran first and established
cds.context via `cds._with(EventContext.for({id,http:{req,res}}), next)`.
/preview/render is mounted in cds.on('bootstrap') on the RAW Express app,
outside that middleware, so cds.context was undefined and ias_auth threw
→ caught → 401 even for a valid token. (/author/* authenticated fine
because those ARE CAP service routes with context; the a2a reference mw
documents the same 'MUST run after contextMw' requirement.)

Fix: establish a cds.context ourselves exactly as cds-context.js does
(EventContext.for + cds._with == AsyncLocalStorage.run, so it spans
iasMw's async continuation), then invoke iasMw inside it. Verified
cds.EventContext, cds._with, cds.utils.uuid all present at runtime.
…context

fix(srv-sage): establish cds.context before IAS validation on /preview/render
…nder renders

After the IAS auth fix (#3159), /preview/render authenticates and reaches
the renderer, but Hugo exits code 1 with no stdout/stderr → 'Preview render
error' (empty <pre>).

Root cause: the tutorials-srv-sage module shipped NO Hugo scaffold.
preview-renderer.js spawns `hugo --source ./preview-site`, and
preview-site/hugo.toml mounts ../hugo/{layouts,static,assets,data,i18n}
RELATIVE to preview-site/ — so both preview-site/ AND hugo/* must exist as
siblings inside gen/srv-sage/ at runtime. The srv-sage module had no
per-module build-parameters, so neither was staged; Hugo had no site to
build and exited 1 before emitting diagnostics (the documented #1102
empty-<pre> symptom, here caused by a missing scaffold rather than a
missing node binary).

Fix: add build-parameters (builder: custom) to the tutorials-srv-sage
module mirroring the proven tutorials-srv-qa module in .deploy/mta.yaml —
copy preview-site/ and hugo/{layouts,static,assets,data,i18n} into the
module (gen/srv-sage, so repo root is ../../). hugo-extended@0.147.8 is
already a dependency, so the vendor binary installs at CF staging; only
the scaffold was missing.

Verified: mbt build packages preview-site/hugo.toml + hugo/layouts (187) +
static (213) + assets (58) + data (11) + i18n (2) into the mtar's
tutorials-srv-sage/data.zip. Needs DEV redeploy + live preview retest.
fix(srv-sage): stage Hugo preview scaffold into module so /preview/render renders
Follow-up to #3161. Staging preview-site/ + hugo/* into the module made the
droplet overflow the 512M disk-quota at container stage-in:

  CELL/0 ERR tar: ./app/hugo/static/js/chunks: Cannot mkdir: No space left
  on device  → Process has crashed with type: "web" (0/1, crash loop)

hugo/static alone is ~248M (site JS/wasm island assets that
preview-site/hugo.toml mounts). With node_modules + the hugo-extended
vendor binary + per-request Hugo output, 512M disk is not enough.

Fix: memory 512M→1024M, disk-quota 512M→1024M. The proven srv-qa preview
module runs 2048M/1024M with the identical full scaffold; srv-sage is
preview + author APIs only, so 1024M memory with 1024M disk. Keeps the
scaffold approach (needed so Hugo can build) and just gives it room.
fix(srv-sage): raise memory/disk to 1024M for Hugo preview scaffold
- Bump .deploy/mta.yaml 1.44.3 -> 1.44.4 (patch; deploy source of truth per
  deploy-mta.cjs). Headline: SAGE isolated IAS-authenticated backend
  (srv-sage) — removes the embedded PROD XSUAA secret from the SAGE VS Code
  extension (security finding) and replaces it with a dedicated IAS
  public-client PKCE flow + isolated srv-sage module. Verified end-to-end on
  DEV (IMS sign-in + My Tutorials + tutorial preview render):
    #3157 srv-sage IAS bearer validation on /preview/render
    #3159 establish cds.context before IAS validation (bootstrap-route fix)
    #3161 stage Hugo preview scaffold into srv-sage module
    #3162 raise srv-sage memory/disk to 1024M for the scaffold
  Also carries ~73 other merged DEV PRs (data-privacy backend routes
  #3139-3147, concept render/order fixes, navigator search, OOM + CI fixes).

Promotes origin/DEV (2886262) to main.
@jung-thomas
Thomas Jung (jung-thomas) merged commit 0f5b195 into main Nov 21, 2026
9 of 10 checks passed
@jung-thomas
Thomas Jung (jung-thomas) deleted the release/dev-to-main-1.44.4 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