Skip to content

fix: preserve YAML anchors after Helm v4 List unwrap in post-render - #1558

Closed
zanarellidev wants to merge 1 commit into
fluxcd:mainfrom
zanarellidev:fix/postrender-yaml-anchors
Closed

fix: preserve YAML anchors after Helm v4 List unwrap in post-render#1558
zanarellidev wants to merge 1 commit into
fluxcd:mainfrom
zanarellidev:fix/postrender-yaml-anchors

Conversation

@zanarellidev

@zanarellidev zanarellidev commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • Helm v4 annotateAndMerge unwraps kind: List into separate documents while keeping &anchor / *alias markers, which turns valid in-List aliases into cross-document references.
  • Origin labels always run as a post-renderer, so NewResMapFromBytes fails with MalformedYAMLError: yaml: unknown anchor ... referenced even when the HelmRelease has no postRenderers.
  • Inflate aliases in Combined.Run only when parse fails with an unknown-anchor error: re-wrap documents as a List, DeAnchor, re-serialize.

Fixes #1556

Bisect

Test plan

  • go test -count=1 ./internal/postrender/
  • Fail-before / pass-after on Test_OriginLabels_Run_crossDocAnchorsFromListUnwrap (exact unknown anchor 'jobSpec' without inflate)

Helm v4 annotateAndMerge unwraps kind:List into separate documents while
preserving &anchor/*alias markers. That creates cross-document aliases
which OriginLabels (always on) rejects as unknown anchors.

Inflate aliases in Combined.Run by re-wrapping into a List, DeAnchor, and
re-serializing only when ParseAll fails with an unknown-anchor error.

Signed-off-by: zanarelli <zanarelli.dev@gmail.com>
@matheuscscp

matheuscscp commented Aug 4, 2026

Copy link
Copy Markdown
Member

Looks like the bug is in helm, not helm-controller

@matheuscscp matheuscscp closed this Aug 4, 2026
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.

YAML anchors/aliases spanning resources break during post-render: "unknown anchor referenced"

2 participants