Skip to content

fix: preserve keyword markers in themes for default export configuration#1387

Merged
ankita10119 merged 5 commits into
masterfrom
DXCDT-1724
May 20, 2026
Merged

fix: preserve keyword markers in themes for default export configuration#1387
ankita10119 merged 5 commits into
masterfrom
DXCDT-1724

Conversation

@ankita10119
Copy link
Copy Markdown
Contributor

🔧 Changes

Fixes keyword preservation for themes when AUTH0_EXPORT_IDENTIFIERS is false (the default configuration).

Root cause: ThemesHandler used identifiers: ['themeId'] to match local theme entries during keyword preservation. However, themeId is stripped from exported files by default (AUTH0_EXPORT_IDENTIFIERS: false), so the preservation logic could never find a matching identifier and silently skipped preservation, causing keyword markers
like ##CDN_URL## to be overwritten with raw values on re-export.

Changes:

  • ThemesHandler: Added displayName as a secondary identifier alongside themeId, providing a match path for users who have named their theme but do not use AUTH0_EXPORT_IDENTIFIERS
  • getPreservableFieldsFromAssets in keywordPreservation.ts:
    • Fixed the identifier reduce to skip missing identifiers instead of resetting the accumulator, allowing multi-identifier fallback to work correctly
    • Added positional index fallback when registered identifiers are absent from the local file, safe for themes since Auth0 supports only one theme per tenant

📚 References

🔬 Testing

Unit tests added covering the following scenarios:

  1. themeId present in local file (AUTH0_EXPORT_IDENTIFIERS: true) - preserved via themeId identifier
  2. displayName present but not themeId - preserved via displayName identifier
  3. Neither themeId nor displayName present (default export, exact customer scenario) - preserved via positional index fallback
  4. identifiers: [] (no identifiers registered for array type) - NOT preserved, confirming the fallback does not apply to unrecognized arrays

Manual end-to-end test:

  1. Set AUTH0_PRESERVE_KEYWORDS: false in config, run export to get a baseline tenant.yaml
  2. Edit tenant.yaml - replace raw URLs with quoted keyword markers e.g. font_url: '##CDN_URL##/fonts/custom.woff2'
  3. Set AUTH0_PRESERVE_KEYWORDS: true, re-run export
  4. Confirm tenant.yaml still contains ##CDN_URL## markers instead of resolved URLs

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@ankita10119 ankita10119 requested a review from a team as a code owner May 15, 2026 07:00
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 15, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.86%. Comparing base (4a28253) to head (a49c76f).

Files with missing lines Patch % Lines
src/keywordPreservation.ts 71.42% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1387      +/-   ##
==========================================
- Coverage   79.87%   79.86%   -0.01%     
==========================================
  Files         153      153              
  Lines        7060     7064       +4     
  Branches     1548     1550       +2     
==========================================
+ Hits         5639     5642       +3     
  Misses        781      781              
- Partials      640      641       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ankita10119 ankita10119 requested a review from kushalshit27 May 18, 2026 05:43
Comment thread src/tools/auth0/handlers/themes.ts Outdated
kushalshit27
kushalshit27 previously approved these changes May 18, 2026
Copy link
Copy Markdown
Contributor

@kushalshit27 kushalshit27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

kushalshit27
kushalshit27 previously approved these changes May 19, 2026
Comment thread src/keywordPreservation.ts Outdated
Comment on lines +84 to +87
// If identifiers are registered for this resource type but none were found on the
// local array item (e.g. themeId stripped by default export), fall back to positional
// index so keyword markers are still preserved. Safe for singletons like themes.
// If no identifiers are registered at all (unrecognized nested arrays), skip.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: keep the comment generic and as short as possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed and updated

@kushalshit27 kushalshit27 self-requested a review May 19, 2026 07:06
@kushalshit27 kushalshit27 marked this pull request as draft May 20, 2026 06:03
@kushalshit27
Copy link
Copy Markdown
Contributor

Please check the failing tests

@ankita10119 ankita10119 marked this pull request as ready for review May 20, 2026 08:27
@ankita10119 ankita10119 merged commit 0326e38 into master May 20, 2026
9 checks passed
@ankita10119 ankita10119 deleted the DXCDT-1724 branch May 20, 2026 09:33
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.

3 participants