fix: three correctness bugs in context parsing, the memory cache and the Scaleway search - #295
Open
ZeikoFr wants to merge 3 commits into
Open
fix: three correctness bugs in context parsing, the memory cache and the Scaleway search#295ZeikoFr wants to merge 3 commits into
ZeikoFr wants to merge 3 commits into
Conversation
This was referenced Aug 30, 2026
…king GetContextNames dereferenced the result of valueOf(contextNode, "name") unconditionally. valueOf returns nil when the entry is not a mapping or has no "name" key, so a hand-edited or provider-generated kubeconfig whose contexts list holds such an entry crashed the whole search with a nil pointer dereference rather than skipping the entry. The added test panics without the guard. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
memoryCache.GetKubeconfigForPath read and wrote its map without synchronisation. Nothing calls it concurrently today, so the race is latent, but any store or caller that retrieves several kubeconfigs at once turns it into a "fatal error: concurrent map writes" crash. The upstream call is deliberately made without holding the lock: it is a remote call taking seconds and would otherwise serialise every caller. The added test fails under -race without the mutex. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…hers
Three problems in the Scaleway search:
- ListProjects and ListClusters were called without scw.WithAllPages, so the
SDK requested a single page. Every project past the server-side default
page size, and every cluster past it within a project, was silently
missing from the search results.
- A project whose cluster listing fails, typically one the credentials
cannot read, aborted StartSearch. The clusters of every project after it
were never reported. The error is now reported and the search carries on.
- The "failed to create Kubernetes API instance" error wrapped err, which is
necessarily nil in that branch, so the message ended in "%!w(<nil>)".
Adds a fake Scaleway API serving paginated project and cluster listings; both
new tests fail against the previous behaviour.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ZeikoFr
force-pushed
the
fix/search-correctness
branch
from
August 30, 2026 13:25
e0545a7 to
f73db95
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.
Three independent bugs found while profiling the live search. Each commit is
self-contained and comes with a test that fails against the current behaviour.
GetContextNamespanics on a context entry without a namevalueOf(contextNode, "name")returnsnilwhen the entry is not a mapping orhas no
namekey, and the result was dereferenced unconditionally. One suchentry in a kubeconfig crashes the whole search with a nil pointer dereference
instead of being skipped.
The in-memory kubeconfig cache is unsynchronised
memoryCache.GetKubeconfigForPathreads and writes its map without a lock.Nothing calls it concurrently today, so this is latent, but any caller that
retrieves several kubeconfigs at once turns it into
fatal error: concurrent map writes. The added test fails under-race.The upstream call is deliberately made without holding the lock: it is a remote
call taking seconds and would otherwise serialise every caller.
The Scaleway search loses clusters
ListProjectsandListClusterswere called withoutscw.WithAllPages(), sothe SDK requested a single page. Every project past the server-side default
page size, and every cluster past it within a project, was silently missing
from the results.
read, aborted
StartSearchentirely. Every project after it was neverreported. The error is now surfaced and the search continues.
errthat isnecessarily
nilin that branch, so the message ended in%!w(<nil>).Verification
gofmt,go build,go vet,golangci-lint run(0 issues) andgo test -race -count=1 ./...are clean, and every commit passes themindividually.
🤖 Generated with Claude Code