Skip to content

fix(kubernetes): reject unsuccessful watch responses - #5076

Merged
asim merged 1 commit into
micro:masterfrom
shuaiyafei:codex/kubernetes-watch-status
Nov 25, 2026
Merged

asim merged 1 commit into
micro:masterfrom
shuaiyafei:codex/kubernetes-watch-status

Conversation

@shuaiyafei

@shuaiyafei shuaiyafei commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Added regressions for 401, 403, and 500: all three fail on unchanged master (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 harness

All commands above passed locally on macOS/Go 1.26.11. TERM=dumb avoids the existing OSC 8 hyperlink counting failures in TestStreamedReferenceLinks, 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 codex label; 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 existing TestStreamedReferenceLinks test and its four hyperlink-counting subcases (run). I reran go test ./cmd/micro/chat -run TestStreamedReferenceLinks -count=1 with TERM unset on unchanged base 65def6c and on this head: both fail on exactly the same four subcases. The full local suite and harness pass with TERM=dumb, as listed above. No CI result was overridden.

@asim
asim merged commit 0eeeb8d into micro:master Nov 25, 2026
3 of 4 checks passed
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.

2 participants