fix(import): preserve env-locale pairing for AM asset publish (DX-9772) - #311
fix(import): preserve env-locale pairing for AM asset publish (DX-9772)#311naman-contentstack wants to merge 2 commits into
Conversation
publishAmSpaces flattened each asset's publish_details into independent environments[] and locales[] arrays, so the CMA republished the cartesian product. For a ragged AM publish state (different locales per environment) this over-published to env-locale pairs that never existed on the source. 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). Scope: AM (publishAmSpaces) only. The legacy publish() path carries the same flatten and will be fixed on development, then back-merged. 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. |
🔒 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
publishAmSpacesflattened each AM asset'spublish_detailsinto two independent arrays (environments[],locales[]) and handed them to the CMA publish endpoint, which republishes the cartesian product env × locale. AM 2.0 assets are published per-(env,locale) independently, so their publish state is routinely ragged — and the flatten then over-publishes to env-locale pairs that never existed on the source stack (silent: CLI reports success).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 one call (unchanged behavior + request count); only ragged assets fan out.Repro (verified)
pub-check-stackassetam3bd5a226c4fb7c95=[new/en-us, new/ar, blt5795/en-us]. Before: flatten → envs[new, blt5795]× locales[en-us, ar]→ phantomblt5795/ar. After: two calls —{new: [en-us, ar]},{blt5795: [en-us]}, no phantom.Notes
publishAmSpacesonly (thisv2-devtrack). The legacypublish()path carries the same flatten and is fixed ondevelopment(PR fix(import): preserve env-locale pairing for asset publish (DX-9772) #310); it will reconcile here on backmerge. Heads-up: that backmerge will conflict on the sharedbuildPublishGroupshelper (already present here) — keep one copy and let the legacypublish()edits land.contentstack-bulk-operationshas the same flatten (DX-9484).Tests
assets.test.ts— addedbuildPublishGroupsunit block (ragged→multi, rectangular→1, 1×1, DX-1656 env-drop, empty). 75 passing.