Repository navigation
fix(kubernetes): reject unsuccessful watch responses - #5076
Merged
Merged
Conversation
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.
Summary
Kubernetes watch requests returning HTTP 401, 403, or 500 currently produce a successful watcher. The error body is consumed as if it were a watch stream, so callers cannot distinguish rejected credentials/RBAC or a server failure from an established watch. Found by reading the new Kubernetes client, then reproduced with local HTTP fixtures.
Reject non-200 responses before starting the body watcher, cancel the request, and close its response body. The existing successful watch behavior is unchanged.
Verification
65def6c) and pass with the fix.go test -race ./registry/kubernetes/...go build ./...golangci-lint run ./...(v2.14.0)TERM=dumb go test -json -timeout 120s ./...TERM=dumb make harnessAll commands above passed locally on macOS/Go 1.26.11.
TERM=dumbavoids the existing OSC 8 hyperlink counting failures inTestStreamedReferenceLinks, previously reproduced on unchanged master; this PR does not change terminal rendering. Tests use loopback HTTP servers, not a live Kubernetes cluster. Remote CI results are not claimed here.AI assistance: implemented and self-reviewed with OpenAI Codex (GPT-6, autonomous). The repository asks for the
codexlabel; my fork contributor permissions do not allow adding upstream labels. Auto-merge has not been enabled.Current remote CI
Lint, Etcd Integration Tests, and End-to-end tests passed for
1f6a717. Unit Tests is red only on the existingTestStreamedReferenceLinkstest and its four hyperlink-counting subcases (run). I rerango test ./cmd/micro/chat -run TestStreamedReferenceLinks -count=1withTERMunset on unchanged base65def6cand on this head: both fail on exactly the same four subcases. The full local suite and harness pass withTERM=dumb, as listed above. No CI result was overridden.