Skip to content

fix(audit): scope asset publish details audit to the exported stack - #326

Open
naman-contentstack wants to merge 2 commits into
v2-devfrom
fix/DX-9739
Open

fix(audit): scope asset publish details audit to the exported stack#326
naman-contentstack wants to merge 2 commits into
v2-devfrom
fix/DX-9739

Conversation

@naman-contentstack

Copy link
Copy Markdown
Contributor

Problem

An Asset Management asset lives in a space and can be published into multiple stacks, so its exported publish_details carry one entry per target stack, each tagged with that stack's api_key. The assets audit validated every entry against the exported stack's locales and environments, so entries belonging to other stacks were reported as missing locale/environment, stripped in fix mode, and raised the "proceed with implementing the fix" confirmation that blocks unattended cm:stacks:import.

Fix

  • Resolve the exported stack's api key from stack/stack.json and validate only publish details for that stack, plus legacy entries that carry no api_key. Entries owned by other stacks are left untouched and never reported. This matches the scoping the import publish step already applies.
  • When the api key cannot be resolved, entries tagged with an api_key are left unchanged instead of being stripped, with a single warning naming the missing file.
  • Audit warnings now state whether the locale, the environment, or both are missing, instead of "locale X or environment Y".
  • Fix mode writes a chunk file (and asks for confirmation) only when that chunk actually changed.

🤖 Generated with Claude Code

An Asset Management asset is shared across stacks and carries publish details
for every stack it was published into, each tagged with that stack's api_key.
The assets audit validated all of them against this export's locales and
environments, so publish details belonging to other stacks were reported as
missing environments/locales, stripped in fix mode, and triggered the fix
confirmation prompt during import.

The audit now resolves the exported stack's api key from stack/stack.json and
validates only publish details for that stack, plus legacy ones without an
api_key. Entries that cannot be attributed are left untouched and warned about
once. Warning messages now name whether the locale, the environment, or both
are missing, and fix mode writes a chunk only when it actually changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@naman-contentstack
naman-contentstack requested a review from a team as a code owner August 1, 2026 09:37
@snyk-io

snyk-io Bot commented Aug 1, 2026

Copy link
Copy Markdown

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

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

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

@naman-contentstack naman-contentstack self-assigned this Aug 1, 2026
Surface the cross-stack skip count at info level: it is the one number that
tells an operator the scoping engaged, and at debug it never appears in a
normal run.

Add the cases the fix was missing:
- an export whose assets are published only into other stacks reports nothing
  and prompts for nothing, which is the empty assets result cm:stacks:import
  reads as "no fix needed" — the actual ticket symptom, previously only
  asserted by proxy.
- an AM export with no stack/stack.json exercises the unresolved-api-key path
  for real instead of poking the private field, and asserts fix mode leaves
  tagged publish details on disk rather than stripping them.

All four fail when the api_key scoping is disabled.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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