fix: check error before using config in GetKubernetesConfig#314
Draft
wesleyjellis wants to merge 1 commit into
Draft
fix: check error before using config in GetKubernetesConfig#314wesleyjellis wants to merge 1 commit into
wesleyjellis wants to merge 1 commit into
Conversation
ClientConfig() returns a nil config when it errors (e.g. no kubeconfig or an invalid context), but QPS/Burst/Timeout were assigned before the error check, panicking with a nil-pointer dereference instead of returning the error to the caller. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
In
GetKubernetesConfig(src/pkg/k8s.go),config.QPS,config.Burst, andconfig.Timeoutwere assigned before the error check onClientConfig(). When loading the kubeconfig fails (missing kubeconfig, invalid context, etc.),configis nil and the runner panics with a nil-pointer dereference instead of surfacing the actual error. This affects both the shared client bootstrap (GetSharedK8sClient) andRunLeaderElection, which call this function.Fix
Move the field assignments below the error check so the load error is returned to the caller.
Testing
go build ./...andgo test ./pkg/...pass.🤖 Generated with Claude Code