Skip to content

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

Open
naman-contentstack wants to merge 1 commit into
v2-devfrom
fix/DX-9772-v2
Open

fix(import): preserve env-locale pairing for AM asset publish (DX-9772)#311
naman-contentstack wants to merge 1 commit into
v2-devfrom
fix/DX-9772-v2

Conversation

@naman-contentstack

Copy link
Copy Markdown
Contributor

What

publishAmSpaces flattened each AM 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. 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 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 one call (unchanged behavior + request count); only ragged assets fan out.

Repro (verified)

pub-check-stack asset am3bd5a226c4fb7c95 = [new/en-us, new/ar, blt5795/en-us]. Before: flatten → envs [new, blt5795] × locales [en-us, ar] → phantom blt5795/ar. After: two calls — {new: [en-us, ar]}, {blt5795: [en-us]}, no phantom.

Notes

  • Scope: AM publishAmSpaces only (this v2-dev track). The legacy publish() path carries the same flatten and is fixed on development (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 shared buildPublishGroups helper (already present here) — keep one copy and let the legacy publish() edits land.
  • 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.ts — added buildPublishGroups unit block (ragged→multi, rectangular→1, 1×1, DX-1656 env-drop, empty). 75 passing.

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>
@naman-contentstack
naman-contentstack requested a review from a team as a code owner July 24, 2026 11:58
@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