fix: recover from panic in IsMinikubeKubernetes when kubeconfig extensions are plain strings#3217
Open
benmosher wants to merge 3 commits intodevspace-sh:mainfrom
Open
fix: recover from panic in IsMinikubeKubernetes when kubeconfig extensions are plain strings#3217benmosher wants to merge 3 commits intodevspace-sh:mainfrom
benmosher wants to merge 3 commits intodevspace-sh:mainfrom
Conversation
…sions are plain strings
Some tools (e.g. Teleport) write kubeconfig cluster extensions as raw
YAML strings rather than structured objects. When devspace calls
runtime.DefaultUnstructuredConverter.ToUnstructured() on such an
extension, the k8s apimachinery reflection layer panics instead of
returning an error:
panic: reflect.Set: value of type string is not assignable to
type map[string]interface {}
Extract the per-extension check into a helper (isMinikubeExtension)
that uses recover() to catch the panic and treat unparseable extensions
as non-minikube, allowing the build to proceed normally.
✅ Deploy Preview for devspace-docs canceled.Built without sensitive environment variables
|
…anic
Covers the cases for IsMinikubeKubernetes:
- nil client / nil ClientConfig
- context name match ("minikube")
- structured extension with minikube provider
- structured extension with a different provider
- string-valued extension (e.g. written by Teleport) — must not panic
Author
|
FWIW -- I am not a Go guy, so this is 100% Claude Code 😅 but this is a real problem I'm experiencing locally. |
Without noinline, newer Go versions inline isMinikubeExtension into its caller, which means the deferred recover() loses its own stack frame and cannot catch the panic from ToUnstructured.
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
When using a Teleport-managed kubeconfig,
devspace build(and any pipeline that callsbuild_images) panics and crashes:Root cause
Teleport writes kubeconfig cluster extensions as plain YAML strings, e.g.:
The Kubernetes spec says extension values should be structured objects.
runtime.DefaultUnstructuredConverter.ToUnstructured()uses reflection and assumes the extension value is a struct/map — it panics (rather than returning an error) when it encounters a plain string.Fix
Extract the per-extension check into a small helper
isMinikubeExtensionthat wraps theToUnstructuredcall withrecover(). A malformed/unparseable extension is treated as non-minikube and the build proceeds normally. No behaviour change on the happy path.Reproduction
devspace buildConfirmed on devspace v6.3.2 and v6.3.20.