-
Notifications
You must be signed in to change notification settings - Fork 78
fix: handle ContentTypeError in dynamic client discovery #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When the Kubernetes API server returns a 503 Service Unavailable with text/plain content type instead of JSON, the dynamic client was failing with a ContentTypeError while trying to parse the response. This fix catches ContentTypeError in the get_resources_for_api_version method and handles it the same way as ServiceUnavailableError, allowing the client to gracefully continue with an empty resources list. This resolves issues when accessing certain API endpoints that may temporarily return non-JSON responses during service unavailability
Any updates ? |
@@ -183,7 +184,9 @@ async def get_resources_for_api_version(self, prefix, group, version, preferred) | |||
try: | |||
response = await self.client.request('GET', path) | |||
resources_response = response.resources or [] | |||
except ServiceUnavailableError: | |||
except (ServiceUnavailableError, ContentTypeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your contribution
Could you fix order of imports as Flake suggests? |
Fix import sorting
Fix import sorting
Ack. Fixed the import sorting and verified it locally.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #368 +/- ##
=======================================
Coverage 27.07% 27.07%
=======================================
Files 805 805
Lines 98735 98736 +1
=======================================
+ Hits 26732 26733 +1
Misses 72003 72003 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fix: handle ContentTypeError in dynamic client discovery
#367
When the Kubernetes API server returns a 503 Service Unavailable with text/plain
content type instead of JSON, the dynamic client was failing with a ContentTypeError
while trying to parse the response. This fix catches ContentTypeError in the
get_resources_for_api_version method and handles it the same way as ServiceUnavailableError,
allowing the client to gracefully continue with an empty resources list.
This resolves issues when accessing certain API endpoints that may temporarily
return non-JSON responses during service unavailability