Skip to content

fix: resolve cross-document YAML anchors broken by Helm v4 post-render#4978

Open
JeffResc wants to merge 3 commits into
zarf-dev:mainfrom
JeffResc:fix/4977-kind-list-anchor-postrender
Open

fix: resolve cross-document YAML anchors broken by Helm v4 post-render#4978
JeffResc wants to merge 3 commits into
zarf-dev:mainfrom
JeffResc:fix/4977-kind-list-anchor-postrender

Conversation

@JeffResc

Copy link
Copy Markdown
Contributor

Description

Deploying a chart that renders a kind: List whose items share a YAML anchor fails post-render with unknown anchor 'shared' referenced. Plain helm install of the same chart succeeds.

Root cause (upstream Helm)

The defect is in Helm v4, not Zarf. Helm runs annotateAndMerge only when a post-renderer is set (Zarf always sets one), and it round-trips manifests through kustomize kio, which flattens a kind: List into separate documents while keeping anchor text, leaving an alias that crosses item boundaries dangling across documents. Fix proposed upstream in helm/helm#32204.

What this PR does

Adds a contained, removable stopgap in getTemplatedManifests, when SortManifests fails, it resolves YAML anchors across the whole manifest stream (inlining cross-document aliases so each document is self-contained) and retries once. It is gated on failure, so working charts are byte-for-byte unchanged. The helper uses goccy/go-yaml, already a Zarf dependency.

This mirrors how Zarf already keeps post-render workarounds in its own code (e.g. namespace handling). The stopgap is tagged for removal in inline comments once a Helm fix is released.

Alternatively, this stopgap can be chosen not to be merged and rather wait for the upstream Helm release, but the tests added in this PR should be helpful in either case as they apply to both the stopgap and the upstream fix.

Tests

  • Unit: TestResolveCrossDocumentAnchors, cross-document mapping alias, sequence alias, and a no-anchor case; each repair case first asserts the unrepaired stream genuinely breaks SortManifests.
  • E2E regression: new 27-kind-list-anchor package + TestKindListAnchor deploying the kind: List anchor chart and asserting both ConfigMaps resolve to data.key = value.

Related Issue

Fixes #4977.

Checklist before merging

@JeffResc JeffResc requested review from a team as code owners June 11, 2026 04:29
@netlify

netlify Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 40e98c4
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6a395051149f4a0008604b11

zarf-dev#4977)

Signed-off-by: Jeff Rescignano <jeffr@defenseunicorns.com>
@JeffResc JeffResc force-pushed the fix/4977-kind-list-anchor-postrender branch from 37ecab9 to 2141c99 Compare June 11, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Post-render fails with unknown anchor … referenced on kind: List

2 participants