Skip to content

fix(action): return correct error variable in prepareUpgrade#32008

Merged
gjenkins8 merged 1 commit intohelm:mainfrom
rhysmcneill:bugfix/helm-upgrade-err-variable-defect
Apr 20, 2026
Merged

fix(action): return correct error variable in prepareUpgrade#32008
gjenkins8 merged 1 commit intohelm:mainfrom
rhysmcneill:bugfix/helm-upgrade-err-variable-defect

Conversation

@rhysmcneill
Copy link
Copy Markdown
Contributor

Closes #32007

What this PR does / why we need it:

During an upgrade, if the last release is not in a deployed state, Helm fetches the currently deployed release and converts it. If that conversion fails, the wrong error variable is returned — the error from the fetch (which is nil on success) rather than the actual conversion error. This silently swallows the failure, returning nil across the board, which could cause a nil pointer panic further down the call chain.

This PR fixes the single-line variable mix-up so the correct error is propagated.

Special notes for your reviewer:

All existing upgrade tests pass locally. A dedicated regression test for this path is not straightforward to add because the storage layer is a concrete type rather than an interface, so the conversion failure cannot be triggered with the current test infrastructure. Happy to discuss a follow-up if maintainers would like that addressed separately.

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 Deployed() succeeds but releaserToV1Release() fails, prepareUpgrade
returned err (nil) instead of cerr (the conversion error), causing a
silent nil return that could lead to nil pointer dereferences downstream.

Closes helm#32007

Signed-off-by: Rhys McNeill <rhysmcneill7@hotmail.co.uk>
Copilot AI review requested due to automatic review settings April 5, 2026 14:59
@pull-request-size pull-request-size Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the prepareUpgrade function in pkg/action/upgrade.go where the wrong error variable is returned when release conversion fails. When the Deployed() call succeeds but the subsequent conversion to V1 format fails, the code was returning the error from the Deployed() call (which is nil) instead of the conversion error, silently swallowing the failure. This could cause nil pointer dereferences downstream.

Changes:

  • Fixed line 256 in pkg/action/upgrade.go to return cerr instead of err when release conversion fails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
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

@TerryHowe TerryHowe added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Apr 19, 2026
@gjenkins8 gjenkins8 merged commit 66e5049 into helm:main Apr 20, 2026
8 of 9 checks passed
@gjenkins8 gjenkins8 removed the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Apr 20, 2026
@gjenkins8
Copy link
Copy Markdown
Member

Good catch. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: prepareUpgrade returns wrong error variable when release conversion fails

4 participants