Skip to content

fix(import): preserve env-locale pairing for asset publish (DX-9772)#310

Open
naman-contentstack wants to merge 1 commit into
developmentfrom
fix/DX-9772-v1
Open

fix(import): preserve env-locale pairing for asset publish (DX-9772)#310
naman-contentstack wants to merge 1 commit into
developmentfrom
fix/DX-9772-v1

Conversation

@naman-contentstack

Copy link
Copy Markdown
Contributor

What

Asset publish (ImportAssets.publish()) flattened each asset's publish_details into 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 buildPublishGroups helper: group publish_details by 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 (phantom production/fr-fr, preview/en-us). After: exactly the 2 source pairs.

Notes

  • Scope: legacy publish() only (this development track). The AM publishAmSpaces path carries the same flatten and is fixed separately on v2-dev; both will reconcile on backmerge (heads-up: the shared buildPublishGroups helper will conflict as a duplicate — keep one copy).
  • Preserves DX-1656 (invalid-environment guard): environments absent from the destination are still skipped.
  • Sibling, out of scope: contentstack-bulk-operations has the same flatten (DX-9484).

Tests

assets.test.tsbuildPublishGroups unit block (ragged→multi, rectangular→1, 1×1, DX-1656 env-drop, empty) + ragged regression through publish(). 69 passing.

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>
@naman-contentstack
naman-contentstack requested a review from a team as a code owner July 24, 2026 11:54
@naman-contentstack naman-contentstack self-assigned this Jul 24, 2026
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 1 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

⚠️ Warning: The following vulnerabilities have exceeded their SLA thresholds (days since publication).

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 1 90 / 365 days ⚠️ Warning
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ 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:

  • Critical without fixes: 0
  • High without fixes: 0
  • Medium without fixes: 1
  • Low without fixes: 0

⚠️ BUILD PASSED WITH WARNINGS - SLA breaches detected for issues without available fixes

Consider reviewing these vulnerabilities when fixes become available.

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.

1 participant