Skip to content

fix: check error before using config in GetKubernetesConfig#314

Draft
wesleyjellis wants to merge 1 commit into
mainfrom
fix/k8s-config-nil-deref
Draft

fix: check error before using config in GetKubernetesConfig#314
wesleyjellis wants to merge 1 commit into
mainfrom
fix/k8s-config-nil-deref

Conversation

@wesleyjellis

Copy link
Copy Markdown

Problem

In GetKubernetesConfig (src/pkg/k8s.go), config.QPS, config.Burst, and config.Timeout were assigned before the error check on ClientConfig(). When loading the kubeconfig fails (missing kubeconfig, invalid context, etc.), config is nil and the runner panics with a nil-pointer dereference instead of surfacing the actual error. This affects both the shared client bootstrap (GetSharedK8sClient) and RunLeaderElection, 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 ./... and go test ./pkg/... pass.

🤖 Generated with Claude Code

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>
@wesleyjellis wesleyjellis self-assigned this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant