fix(secret): read pinnable secrets with dig to survive --reuse-values - #11
Merged
Merged
Conversation
`helm upgrade --reuse-values` from any chart <= 0.3.5 to 0.3.6 failed to
render:
secret.yaml:45:75: executing "patchmon/templates/secret.yaml" at
<.Values.patchmon.session.secret>: nil pointer evaluating interface {}.secret
--reuse-values substitutes the previous release's values for the incoming
chart's defaults instead of merging them, so 0.3.6's new
patchmon.session.secret and patchmon.encryption.aiKey defaults are never
coalesced in. A release created before those keys existed has no
patchmon.session or patchmon.encryption map at all, and dereferencing the
absent parent aborts the render.
patchmon.jwt.secret was unaffected only because patchmon.jwt predates the
keys added in #7, so every stored release already carries it.
Reading all three through `dig` makes the parent lookup total: an absent map
yields the "" default and falls through to the existing lookup on the live
Secret, preserving the current values exactly as before. Explicitly set
values still win, and empty values still generate.
The failure is only reachable via --reuse-values; a fresh install or `-f
values.yaml` coalesces chart defaults normally, which is why CI did not catch
it. An upgrade-path test would.
Refs: #10
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W8fLdB23wUNywajvRtNYbt
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.
Fixes #10.
The bug
helm upgrade --reuse-valuesfrom any chart ≤ 0.3.5 to 0.3.6 aborts at render:--reuse-valuessubstitutes the previous release's values for the incoming chart'sdefaults rather than merging them, so 0.3.6's new
patchmon.session.secretandpatchmon.encryption.aiKeydefaults are never coalesced in. A release created beforethose keys existed has no
patchmon.session/patchmon.encryptionmap at all, anddereferencing the absent parent aborts the render.
patchmon.jwt.secreton the line above was unaffected only becausepatchmon.jwtpredates the keys added in #7, so every stored release already carries it.
This is the ordinary upgrade path for anyone whose values live outside git, and every
existing user is on ≤ 0.3.5 by definition.
The fix
Read all three through
dig, which makes the parent lookup total — an absent mapyields the
""default and falls through to the existinglookupon the live Secret:jwtis included for uniformity — it is equivalent today, and it stops the same classof bug reappearing if that map is ever absent.
Chart bumped 0.3.6 → 0.3.7.
Verification
Reproduced deterministically with
--set patchmon.session=null --set patchmon.encryption=null,which forces the same nil parent:
nil pointer evaluating interface {}.secretSemantics unchanged:
--set patchmon.jwt.secret=MYJWTetc. renderMYJWT,MYSESSION,MYAIKEYrandAlphaNumlookupfallback is untouched, so existing releases keep their current secretshelm lintclean, both with defaults and with this deployment's shape(
database.mode=external,guacd.enabled=false).Chart.lockuntouched, so the"Ensure Chart.lock wasn't modified by CI" check passes.
Out of scope, but noted
--set patchmon.jwt=nullstill fails — inconfigmap-server.yaml:16on.Values.patchmon.jwt.expiresIn, not insecret.yaml. That is the same patternelsewhere in the chart, but it is not reachable through
--reuse-valuesbecausepatchmon.jwthas always existed. Worth an audit pass separately; any value added toan existing map in a future chart version has this problem.
Also worth considering: CI installs the chart fresh, which passes, so it could not have
caught an upgrade-path regression. A test that installs an older chart and upgrades with
--reuse-valueswould.