Skip to content

feat(admin): allow external https URL in tutorial redirect (#2690) - #2694

Merged
jung-thomas merged 1 commit into
DEVfrom
feat/redirect-external-url-2690
Oct 8, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
feat/redirect-external-url-2690

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Closes #2690

Problem

A tutorial's redirect field (redirectTo) is an Association to Tutorials — it can only point at another tutorial. Authors who tried to enter a full external URL (e.g. redirect a deleted tutorial to a community.sap.com page) were blocked, because the picker + validation only accept a valid tutorial.

Change

Add a sibling redirectUrl free-text field alongside redirectTo, keeping the existing slug value-help and validation untouched.

  • Schema (db/schema.cds, db-qa/schema.cds): new redirectUrl : String(1000).
  • Validation (srv/admin-service.js): redirectUrl must be set on an INACTIVE tutorial, must pass the existing SAP host allowlist (isAllowedTarget — https:// on community.sap.com / help.sap.com / www.sap.com / etc.), and is mutually exclusive with redirectTo.
  • Serve-time 301: packages/content/content-store.js (tutorial HTML) and srv/lib/model-json-handler.js (Discovery Center .model.json) now 301 to the external URL first, falling back to the existing slug→slug redirect. packages/core/_tutorials-table.js adds redirectUrlCol for the raw serve SELECT.
  • Admin UI (app/admin-annotations.cds): free-text "Redirect URL (external)" field next to the Redirect To picker, with placeholder + description noting the allowlist.

URL policy

External URLs go through the existing PR-reviewed SAP host allowlist (srv/lib/redirect-allowlist.js) rather than allowing arbitrary https://*, matching the repo's established redirect security posture. Arbitrary external hosts remain blocked from the UI; adding a host stays a deliberate code edit.

Tests (TDD)

  • test/admin-service.test.js: accept allowlisted https on INACTIVE; reject non-allowlisted host, non-https, ACTIVE-tutorial, and both-set.
  • test/lib/content-store.test.js: 301 to external URL (query preserved).
  • srv/__tests__/lib/model-json-route.test.js: 301 to external URL on .model.json.

All 95 tests across the three affected files pass. Pre-existing unrelated failures in the full suite (missing *.bundle.mjs build artifacts and @mediapipe native deps in a fresh worktree) are environmental, not from this change.

🤖 Generated with Claude Code

Tutorials could only redirect to another tutorial via the redirectTo
association, so authors were blocked from redirecting a deleted tutorial
to an off-platform page. Add a redirectUrl string field that accepts an
https:// URL on the curated SAP host allowlist (reusing isAllowedTarget
from redirect-allowlist.js), keeping the existing slug value-help +
validation on redirectTo untouched.

- db/schema.cds + db-qa/schema.cds: new redirectUrl String(1000)
- packages/core/_tutorials-table.js: redirectUrlCol for the raw serve SELECT
- srv/admin-service.js: validate redirectUrl (INACTIVE-only, allowlisted
  https, mutually exclusive with redirectTo)
- packages/content/content-store.js + srv/lib/model-json-handler.js:
  honor redirectUrl first (301 to the external URL), else slug redirect
- app/admin-annotations.cds: free-text "Redirect URL (external)" field
  next to the Redirect To picker
@jung-thomas
jung-thomas force-pushed the feat/redirect-external-url-2690 branch from f46d6bd to 561cd81 Compare October 8, 2026 16:37
@jung-thomas
jung-thomas merged commit 73657ae into DEV Oct 8, 2026
7 checks passed
@jung-thomas
jung-thomas deleted the feat/redirect-external-url-2690 branch October 8, 2026 18:10
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