fix(api): nil pointer panic when Helm chart has no liveness probe#2513
Closed
A386official wants to merge 1 commit intogoodrain:mainfrom
Closed
fix(api): nil pointer panic when Helm chart has no liveness probe#2513A386official wants to merge 1 commit intogoodrain:mainfrom
A386official wants to merge 1 commit intogoodrain:mainfrom
Conversation
When a container has only a readiness probe (no liveness probe), the readiness probe handler incorrectly referenced `livenessProbe.HTTPGet` instead of `readinessProbe.HTTPGet` for the named-port fallback lookup. Since livenessProbe is nil in the else branch, this causes a nil pointer dereference panic when parsing Helm charts without liveness probe config. Fixes #2512 Signed-off-by: A386official <A386official@users.noreply.github.com>
b99a146 to
c0d8b51
Compare
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.
Bug
When deploying a Helm chart application that has a readiness probe but no liveness probe configured, the API panics with a nil pointer dereference at
resource_public_function.go:332, returning no useful error to the user. This was reported in #2512 with a full stack trace.Root Cause
In
PodTemplateSpecResource(), the readiness probe handling block (theelsebranch, entered whenlivenessProbe == nil) contains a copy-paste bug on line 332:The named-port fallback lookup incorrectly references
livenessProbe.HTTPGet.Port.StrValinstead ofreadinessProbe.HTTPGet.Port.StrVal. SincelivenessProbeis guaranteed to benilin theelsebranch, dereferencing it causes a panic.Fix
Change
livenessProbetoreadinessProbeon the affected line, matching the surrounding code's intent:This is a one-line, surgical fix that corrects the variable reference to match the enclosing scope. No behavior change for the liveness probe path.
Closes #2512