Skip to content

MWPW-191949: maybe taking care of langfirst=false bug#5914

Closed
sheridansunier wants to merge 2 commits into
adobecom:stagefrom
sheridansunier:MWPW-191949
Closed

MWPW-191949: maybe taking care of langfirst=false bug#5914
sheridansunier wants to merge 2 commits into
adobecom:stagefrom
sheridansunier:MWPW-191949

Conversation

@sheridansunier

@sheridansunier sheridansunier commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Root cause: getConfig() in libs/blocks/caas/utils.js was resolving country/lang via the Milo locale system (getCountryAndLang). On LangFirst pages, Milo strips the country from the URL prefix (e.g. /de/country='de', lang='en'), while the Lingo mapping correctly returns lang='de', country='xx' — the pair that passes the isPermittedLingoSiteLocale check. This caused getLangFirstParam to return false, so the CaaS URL included &langFirst=false instead of &langFirst=true.
  • Fix: getConfig() now resolves country/lang via getLanguageFirstCountryAndLang(pathname, primeSource, fqdn) — a Lingo site-mapping lookup — before calling getLangFirstParam.
  • Bulk publisher: Derives floodgate color from the host URL (-fg-{color} suffix) instead of relying solely on the dropdown, and warms the lingo mapping cache before the publish loop via initBulkPublisherLingoMapping().
  • Reliability: Added runLanguageFirstRetry — retries the lingo mapping lookup up to 3× when it fails transiently (indicated by fromFallback: true), preventing silent langFirst=false on network blips.
  • Caching: fetchLingoSiteMapping() deduplicates the lingo-site-mapping.json network call to one Promise per session.

Before / After

Scenario Before After
/de/ bacom page with <meta langfirst=on> &langFirst=false &langFirst=true
Non-LangFirst locale (e.g. /jp/) &langFirst=false &langFirst=false (unchanged)
source: news &langFirst=true &langFirst=true (unchanged)

Changes

File Change
libs/blocks/caas/utils.js Core fix: getConfig() now calls getLanguageFirstCountryAndLang instead of getCountryAndLang for langFirst resolution. Also: lingo mapping cache (fetchLingoSiteMapping), fromFallback propagation, state.floodgateColor replaces hardcoded 'pink', localFirst/localLast sort options, current-page UUID in excludedIds
tools/send-to-caas/send-utils.js LANG_FIRST_SOURCE_MAPPINGS constant; getFloodgateColorFromHost(); processRepoForFloodgate handles -fg-{color}; runLanguageFirstRetry() with retry logic
tools/send-to-caas/bulk-publish-to-caas.js Derives floodgateColor from host; calls initBulkPublisherLingoMapping() before loop
test/blocks/caas/utils.test.js Three new tests: lingo-known locale → &langFirst=true, unknown locale → &langFirst=false, news source always → &langFirst=true

Constitution Check

Principle Status
2 — Performance fetchLingoSiteMapping caches the Promise; N→1 fetch per session
3 — Accessibility ✅ Not applicable
5 — Localization by Design ✅ Core fix: Lingo mapping now used for CaaS langFirst resolution
6 — Tested or It Didn't Happen ✅ 3377 tests pass; runLanguageFirstRetry, getFloodgateColorFromHost, initBulkPublisherLingoMapping, and the getConfig() langFirst path (including news source) are all covered
8 — Security and Data Minimization ✅ LANA logs use tags/severity; no PII

Test plan

Automated

  • npm run test — 3377 passed, 0 failed
  • npx eslint on changed files — clean
  • getConfig() with mocked lingo mapping: /de/ (known lingo locale) → &langFirst=true
  • getConfig() with mocked lingo mapping: /jp/ (unknown locale) → &langFirst=false
  • getConfig() with source: ['news']&langFirst=true (news override unchanged)
  • Existing: runLanguageFirstRetry (4 cases), getFloodgateColorFromHost (4 cases), initBulkPublisherLingoMapping (cache-overwrite)

Manual smoke test

  • Opened business.adobe.com/de/resources.html in DevTools → Network → filtered "chimera". Confirmed langfirst meta is on and both CaaS collection requests contain &langFirst=true

Repro steps for reviewer: On business.adobe.com/de/resources.html (or any bacom LangFirst page), open DevTools → Network → filter "chimera". Confirm &langFirst=true appears in the CaaS request URL. Without this fix, the same page returns &langFirst=false.

Suggested reviewer checks

  • Regression (no langFirst meta): Load a CaaS page without <meta name="langfirst">. Confirm langFirst is absent from the CaaS URL entirely.
  • Regression (non-Lingo source): Load a page using a non-Lingo CaaS source. Confirm langFirst is not incorrectly true.
  • Lingo mapping cache: On a page with multiple CaaS blocks sharing a Lingo source, confirm only one lingo-site-mapping.json request fires in the Network tab.
  • Bulk publisher floodgate color: From a -fg-pink AEM branch host, open the bulk publisher and confirm the floodgate color is pre-populated as 'pink' without manual selection.
  • floodgateColor default: On a non-floodgate host, confirm addFloodgateHeader does not send an x-floodgate-color header.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has not been updated recently and will be closed in 7 days if no action is taken. Please ensure all checks are passing, https://github.com/orgs/adobecom/discussions/997 provides instructions. If the PR is ready to be merged, please mark it with the "Ready for Stage" label.

@github-actions github-actions Bot added the Stale label May 15, 2026
Tests verify the core fix — getConfig() uses getLanguageFirstCountryAndLang
(Lingo site-mapping lookup) for the getLangFirstParam call, not the generic
Milo locale. Covers three cases:
- Known Lingo locale (/de/ mapped to hawks) → &langFirst=true
- Unknown locale (/jp/ not in mapping) → &langFirst=false
- News source always → &langFirst=true (override unchanged, MWPW-191949)

Also adds .specify/* to .gitignore for local-only speckit artifacts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

This PR has not been updated recently and will be closed in 7 days if no action is taken. Please ensure all checks are passing, https://github.com/orgs/adobecom/discussions/997 provides instructions. If the PR is ready to be merged, please mark it with the "Ready for Stage" label.

@github-actions github-actions Bot added the Stale label May 27, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Closing this PR due to inactivity.

@github-actions github-actions Bot closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant