fix: repair Smartling CAT visual context#1360
Open
stevejalim wants to merge 2 commits into
Open
Conversation
GCP IAP is stopping the preview URL being used by CAT, so this changeset rewrites the HTML artifact sent over to try to make the CAT not need anything from the IAP-protected service. (Instead it loads CSS/JS from the public CDN) This changeset also fixes a bug with the callback that was using the published hostname (www.firefox.com) for the preview link, not the internal CMS hostname. (This is somehwat academic because IAP is blocking the CMS host, but it helps us narrow down what may be causing CAT to fail on Smartling) Jira: https://mozilla-hub.atlassian.net/browse/WT-1184
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Smartling visual context callback to avoid relying on an IAP-protected CMS preview origin by rewriting the exported HTML to resolve assets against the public canonical domain, and fixes the preview URL host selection for the Smartling callback.
Changes:
- Build the Smartling preview URL using
settings.WAGTAILADMIN_BASE_URLinstead of the published hostname derived from the WagtailSite. - Post-process the exported HTML to strip the CMS hostname and inject a
<base href="{CANONICAL_URL}/">tag so Smartling resolves relative asset URLs against the public domain. - Extend callback tests to cover the base-tag injection and CMS-hostname stripping behavior.
Assessment / Risks:
- Logging the full draft sharing URL leaks the draft-sharing token into logs (must be addressed).
WAGTAILADMIN_BASE_URLcan be empty by default, which can silently produce a relative URL that likely violates the Smartling callback contract (must be addressed).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
springfield/cms/wagtail_localize_smartling/callbacks.py |
Adjusts Smartling visual context URL construction and rewrites exported HTML to avoid CMS-origin dependencies. |
springfield/cms/tests/test_callbacks.py |
Updates and adds tests for the new URL construction and HTML rewriting behavior. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1360 +/- ##
==========================================
+ Coverage 78.17% 78.19% +0.02%
==========================================
Files 152 152
Lines 10057 10067 +10
==========================================
+ Hits 7862 7872 +10
Misses 2195 2195 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GCP IAP is stopping the preview URL being used by CAT, so this changeset rewrites the HTML artifact sent over to try to make the CAT not need anything from the IAP-protected service. (Instead it loads CSS/JS from the public CDN)
This changeset also fixes a bug with the callback that was using the published hostname (www.firefox.com) for the preview link, not the internal CMS hostname. (This is somehwat academic because IAP is blocking the CMS host, but it helps us narrow down what may be causing CAT to fail on Smartling)
Issue / Bugzilla link
Jira: https://mozilla-hub.atlassian.net/browse/WT-1184
Testing
I've tested this manually locally and it's working fine - hopefully it'll also fix things in a deployed environment. Will test on Dev as soon as it's merged