fix(import): preserve env-locale pairing for asset publish (DX-9772) - #310
Conversation
publish() flattened each asset's publish_details into independent environments[] and locales[] arrays, so the CMA republished the cartesian product. For a ragged publish state (different locales on different environments) this over-published to env-locale pairs that never existed on the source stack. Add buildPublishGroups: group publish_details by environment, coalesce environments with an identical locale set, and emit one publish call per group so each call is a single rectangle the CMA reproduces exactly. A rectangular asset still collapses to one call (unchanged behavior). The DX-1656 invalid-environment guard is preserved (envs absent from the destination are still skipped). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
What
Asset publish (
ImportAssets.publish()) flattened each asset'spublish_detailsinto two independent arrays (environments[],locales[]) and handed them to the CMA publish endpoint, which republishes the cartesian product env × locale. For a ragged publish state (different locales on different environments) this over-published to env-locale pairs that never existed on the source stack — a silent over-publish (CLI reports success; destination gets extra combos).Fix
New
buildPublishGroupshelper: grouppublish_detailsby environment, coalesce environments that share an identical locale set, and emit one publish call per group — so each call is a single rectangle the CMA reproduces exactly. A fully-rectangular asset still collapses to a single call (unchanged behavior); only ragged assets fan out.Repro (verified)
Crafted a ragged legacy asset
bltf91eeb09ee37ef51=[production/en-us, preview/fr-fr]. Before: destination published to 4 pairs (phantomproduction/fr-fr,preview/en-us). After: exactly the 2 source pairs.Notes
publish()only (thisdevelopmenttrack). The AMpublishAmSpacespath carries the same flatten and is fixed separately onv2-dev; both will reconcile on backmerge (heads-up: the sharedbuildPublishGroupshelper will conflict as a duplicate — keep one copy).contentstack-bulk-operationshas the same flatten (DX-9484).Tests
assets.test.ts—buildPublishGroupsunit block (ragged→multi, rectangular→1, 1×1, DX-1656 env-drop, empty) + ragged regression throughpublish(). 69 passing.