Skip to content

fix(bulk-operations): publish only to scoped targets - #354

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

fix(bulk-operations): publish only to scoped targets#354
naman-contentstack wants to merge 1 commit into
developmentfrom
fix/DX-9484

Conversation

@naman-contentstack

@naman-contentstacknaman-contentstack commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What

cm:stacks:bulk-assets published assets to environments and locales they were
never scoped to.

The bulk-publish API is a flat cross product — { items, environments, locales }
expands server-side into one record per (item × locale × environment). Per-item
targets were computed and then collapsed into batch-level arrays, so every item in
a batch inherited the union of that batch.

Fix

Batches are keyed on (locale, environment set), so the arrays sent equal the
batch's real scope.

SiteBeforeAfter
--backup-dir assetsenvs/locales unioned across the whole backup, so a dev-only asset published to every environment in iteach asset publishes to the targets it actually had
revert / retryevery item took the first log entry's environments, unpublishing from environments it never reachedeach item keeps its own log entry's environments
payload builderfell back to items[0].publish_details for the whole batchunion across all items

Multi-environment assets are unaffected: grouping is on the whole environment set,
so an asset in dev+prod still goes out in one request carrying both.

Entries keep entry.locale as the resolution hint while publish_details carries
the requested locale, so fallback-locale publishing still works.

Testing

  • 857 unit tests passing, 0 failing
  • new backup-dir-asset-fetcher.test.ts — the module had zero coverage; includes
    the regression case (a dev-only asset stays dev-only)
  • batch-helper.test.ts previously asserted mixed-locale flattening as correct;
    that expectation is inverted

Per-item environments/locales were collapsed into batch-level arrays,
so every item inherited the batch union: backup-dir assets published
to every environment found in the backup, and revert unpublished using
the first log entry's environments. Batches are now keyed on
(locale, environment set).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@naman-contentstack
naman-contentstack requested a review from a team as a code ownerAugust 19, 2026 07:51
@snyk-io

snyk-ioBot commented Aug 19, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

StatusScan Engine Critical High Medium LowTotal (0)
Open Source Security0000 0 issues
Licenses0000 0 issues
Code Security0000 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

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

Check TypeCount (with fixes)Without fixesThresholdResult
🔴 Critical Severity0010✅ Passed
🟠 High Severity0025✅ Passed
🟡 Medium Severity00500✅ Passed
🔵 Low Severity001000✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

SeverityBreaches (with fixes)Breaches (no fixes)SLA Threshold (with/no fixes)Status
🔴 Critical0015 / 30 days✅ Passed
🟠 High0030 / 120 days✅ Passed
🟡 Medium0090 / 365 days✅ Passed
🔵 Low00180 / 365 days✅ Passed

✅ BUILD PASSED - All security checks passed

@naman-contentstacknaman-contentstack self-assigned this Aug 19, 2026
stats = await scanBackupDirStats(backupDir!, this.logger);
} catch (err: any) {
this.logger.error($t(messages.DATA_DIR_READ_ERROR, { path: dataDir!, error: err.message || String(err) }));
this.logger.error($t(messages.BACKUP_DIR_READ_ERROR, { path: backupDir!, error: err.message || String(err) }));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using this.logger and log directly in this code, why both approaches ?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was being used previously, only updated the message code here

Sign up for freeto 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.

2 participants

@naman-contentstack@shafeeqd959