Repository navigation
fix: return the default from get when a parent value is nil - #2877
Merged
Merged
Conversation
`get "foo.bar" "default" .Values` failed with "unexpected type(<nil>)" when foo exists but is null (for example `foo:` with nothing after it in a values file), instead of returning the default like it does when foo is missing. Signed-off-by: Lucas Barros <[email protected]>
lbarrosby
requested review from
aditmeno,
itscaro,
mumoshu,
xiaomudk,
yxxhero and
zhaque44
as code owners
November 6, 2026 11:05
yxxhero
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
foo:left empty in a values file (sofoois null),{{ .Values | get "foo.bar" "default" }}fails the render with:The docs say
getreturns the default when the path is not found, and that is what happens whenfoois missing altogether. Inget, a nil parent fell into the struct branch, which returns an error without looking at the default. This adds anilcase that returns the default when one was passed. Without a default it still returns anoValueError, sogetkeeps failing andgetOrNilkeeps returning nil.Tested with a new
TestGetWithDefaultThroughNilValue(fails on main),go test ./pkg/tmpl/andgo vet ./pkg/tmpl/pass.