Skip to content

fix(copystructure): handle nil elements in slice copying#31751

Merged
mattfarina merged 1 commit intohelm:mainfrom
gitgrave:fix-31750
Jan 28, 2026
Merged

fix(copystructure): handle nil elements in slice copying#31751
mattfarina merged 1 commit intohelm:mainfrom
gitgrave:fix-31750

Conversation

@tamcore
Copy link
Contributor

@tamcore tamcore commented Jan 22, 2026

Closes #31750

When copying slices containing nil interface{} elements, the copyValue function would panic with reflect: call of reflect.Value.Set on zero Value.

This issue was introduced in v4.1.0 when replacing mitchellh/copystructure with an internal implementation. The fix mirrors the existing nil handling logic used for map values.

Added test case to verify slice elements with nil values are properly handled during deep copy operations.

What this PR does / why we need it:

Special notes for your reviewer:

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

When copying slices containing nil interface{} elements, the copyValue
function would panic with 'reflect: call of reflect.Value.Set on zero
Value'. This occurred because reflect.ValueOf(nil) returns a zero Value
that cannot be set.

This issue was introduced in v4.1.0 when replacing mitchellh/copystructure
with an internal implementation. The fix mirrors the existing nil handling
logic used for map values.

Fixes helm template panic when processing charts with YAML like:
  extraArgs:
    -

Added test case to verify slice elements with nil values are properly
handled during deep copy operations.

Signed-off-by: Philipp Born <git@pborn.eu>
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 22, 2026
Copy link
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

@violuke
Copy link

violuke commented Jan 26, 2026

We're also suffering from this issue. A release with this fixed would be greatly appreciated 🙏 Thank you.

Copy link
Collaborator

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

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

lgtm

@mattfarina mattfarina added this to the 4.1.1 milestone Jan 28, 2026
@mattfarina mattfarina merged commit 75880fa into helm:main Jan 28, 2026
5 checks passed
@scottrigby scottrigby added picked Indicates that a PR has been cherry-picked into the next release candidate. bug Categorizes issue or PR as related to a bug. labels Feb 9, 2026
@joejulian joejulian modified the milestones: 4.1.1, 4.1.2 Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. picked Indicates that a PR has been cherry-picked into the next release candidate. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: reflect: call of reflect.Value.Set on zero Value

6 participants