Skip to content

fix: deep copy values on merge so a chart mapping can't leak into later components - #5585

Merged
a1994sc merged 4 commits into
mainfrom
fix-5584-values-aliasing
Nov 5, 2026
Merged

a1994sc merged 4 commits into
mainfrom
fix-5584-values-aliasing

Conversation

@a1994sc

@a1994sc a1994sc commented Nov 1, 2026

Copy link
Copy Markdown
Member

Description

Values.DeepMerge and Values.Set stored source subtrees by reference, so a destination shared nested maps with its source.

In generateValuesOverrides, a chart's first values mapping (.shared → .) made chartOverrides["nested"] the same map object as the package values tree's shared.nested. The second mapping (.extra → .) then found nested present in both, recursed, and wrote from-extra straight into the package values. Every later component reading .shared got the first component's values, so a render depended on which components were in the command — and the wrong values reached the cluster with no warning.

This also explains why the bug only ever touched nested keys (a top-level key is overwritten in chartOverrides itself, not in the shared tree) and why inspecting a single component looked correct.

The fix stores deepCopyValue(...) instead of the reference, using the helper already in that file. That makes the whole Values API non-aliasing, so no caller can splice a live subtree into a destination and later write through it. It also closes the same aliasing one layer over, at packager.go:105, where the long-lived per-command valuesOverridesMap is merged by reference into the map handed to Helm.

The same bug class was patched at this call site once before, for excludePaths — hence fixing the primitive rather than the caller.

Secondary effect: the zarf-seed-registry / zarf-registry case from the issue now works. Giving the seed registry its own values path no longer rewrites .registry's nested persistence / autoscaling maps.

Tests — each was confirmed to fail before the value.go change and pass after:

  • src/pkg/value/value_test.go — DeepMerge/Set must not hand the destination a live reference into the source.
  • src/pkg/packager/packager_test.go — the issue's scenario at unit level: comp-a's mapping must leave the shared tree untouched, and comp-b must resolve nested.both to from-shared.
  • src/test/e2e/42_values_test.go + src/test/packages/42-values/values-leak/ — package create then package inspect values-files, asserting comp-b's document is identical whether or not comp-a is in the same command. The fixture was validated against a pre-fix binary and reproduced the issue's output exactly.

Related Issue

Fixes #5584

Checklist before merging

…er components

Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc
a1994sc requested review from a team as code owners November 1, 2026 23:19
@netlify

netlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 54972b2
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6aebce2acba491b5470a6218

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pkg/value/value.go 33.33% 4 Missing and 2 partials ⚠️
Files with missing lines Coverage Δ
src/pkg/value/value.go 79.75% <33.33%> (-1.50%) ⬇️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/pkg/value/value.go Resolved
Signed-off-by: Allen Conlon <software@conlon.dev>
Comment thread src/pkg/value/value.go Resolved
Signed-off-by: Allen Conlon <software@conlon.dev>
AustinAbro321
AustinAbro321 previously approved these changes Nov 4, 2026

@AustinAbro321 AustinAbro321 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@brandtkeller brandtkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one minor and possibly negligible item I wanted to discuss otherwise lgtm.

Comment thread src/pkg/value/value.go Resolved
@github-project-automation github-project-automation Bot moved this to In progress in Zarf Nov 5, 2026
Signed-off-by: Allen Conlon <software@conlon.dev>

@brandtkeller brandtkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm - thanks!

@AustinAbro321
AustinAbro321 added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@AustinAbro321
AustinAbro321 added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@a1994sc

a1994sc commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Is there something that I could change to help this merge?

@AustinAbro321

Copy link
Copy Markdown
Member

Nah, gh download links were returning 500

@AustinAbro321
AustinAbro321 added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@a1994sc
a1994sc added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@a1994sc
a1994sc added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 8802592 Nov 5, 2026
31 checks passed
@a1994sc
a1994sc deleted the fix-5584-values-aliasing branch November 5, 2026 16:12
@github-project-automation github-project-automation Bot moved this from In progress to Done in Zarf Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

v1beta1: a chart values mapping changes the package values tree and leaks nested keys into later components

4 participants