client: include response body in ProtocolSwitch error#1984
Open
SebTardif wants to merge 1 commit into
Open
Conversation
When a WebSocket upgrade fails with a non-101 status (e.g. 403 Forbidden), the Kubernetes API server returns a JSON metav1.Status body with the actual error message, reason, and details. Previously this body was discarded, leaving users with only "failed to switch protocol: 403 Forbidden". Change ProtocolSwitch from a tuple variant carrying just the StatusCode to a struct variant carrying both the status and the response body string. Make verify_response async so it can read the body before returning the error. Closes kube-rs#1405 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1984 +/- ##
=======================================
+ Coverage 75.6% 75.7% +0.2%
=======================================
Files 89 89
Lines 8666 8751 +85
=======================================
+ Hits 6544 6622 +78
- Misses 2122 2129 +7
🚀 New features to boost your workflow:
|
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.
What this PR does
Fixes #1405.
When exec, portforward, or attach fails because the Kubernetes API server returns a non-101 response (e.g. 403 Forbidden, 404 Pod Not Found), the HTTP response body, which contains a full
metav1.StatusJSON with message, reason, and details, was discarded. Users saw only:...instead of the actual error:
Changes:
ProtocolSwitch(StatusCode)toProtocolSwitch { status, body }struct variantverify_responseasync to read the response body on failuremod.rsCloses #1405
AI Disclosure
Developed with AI assistance (Grok by xAI) in a human-in-the-loop workflow. All code reviewed and verified by the human author.
Signed-off-by: Sebastien Tardif sebtardif@ncf.ca