This repository was archived by the owner on May 16, 2026. It is now read-only.
fix: support urllib3 2.6.0+ by replacing deprecated getheaders()#1
Open
AmSach wants to merge 1 commit into
Open
fix: support urllib3 2.6.0+ by replacing deprecated getheaders()#1AmSach wants to merge 1 commit into
AmSach wants to merge 1 commit into
Conversation
urllib3 2.6.0 removed getheaders() method in favor of the headers attribute. This caused ApiException and RESTResponse.getheaders() to crash with AttributeError when urllib3 >= 2.6.0 was used. Fix: - RESTResponse.getheaders(): Use getattr to fallback to headers attribute - ApiException.__init__: Use try/except to fallback to headers attribute Fixes kubernetes-client#2477
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
urllib3 2.6.0 removed the
getheaders()method in favor of theheadersattribute. This causes the Kubernetes Python client to crash withAttributeErrorwhen urllib3 >= 2.6.0 is used.Bug Description
When an API exception is raised,
ApiException.__init__callshttp_resp.getheaders()which no longer exists in urllib3 >= 2.6.0. Similarly,RESTResponse.getheaders()also uses the deprecated method.Fix
RESTResponse.getheaders(): Usegetattrto fall back to theheadersattribute whengetheadersis not available.ApiException.__init__: Use try/except to fall back to theheadersattribute whengetheadersraisesAttributeError.This ensures compatibility with both urllib3 < 2.6.0 and urllib3 >= 2.6.0.
Testing
headersattributeRelated Issue
Fixes kubernetes-client#2477