Skip to content

Conversation

@franck-ada
Copy link

What type of PR is this?

/kind bug
/kind deprecation

What this PR does / why we need it:

Correct issue link to upgrade of urlib3

Which issue(s) this PR fixes:

Fixes #2280

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Copilot AI review requested due to automatic review settings December 8, 2025 03:13
@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/deprecation Categorizes issue or PR as related to a feature/enhancement marked for deprecation. labels Dec 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: franck-ada
Once this PR has been reviewed and has the lgtm label, please assign roycaihw for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 8, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: franck-ada / name: Franck P (54bef8f)
  • ✅ login: Naman-cell / name: Naman-cell (3ef6286)

@k8s-ci-robot
Copy link
Contributor

Welcome @franck-ada!

It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 8, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 8, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix header retrieval in the REST client to support urllib3 upgrades by adding compatibility checks for the headers attribute. The changes add conditional logic to use the newer .headers attribute when available, falling back to the older .getheaders() and .getheader() methods for backward compatibility.

Key changes:

  • Add compatibility checks in getheaders() method to use .headers.items() when available
  • Add compatibility checks in getheader() method to use .headers.get() when available

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 44 to 50
if hasattr('headers', self.urllib3_response):
return self.urllib3_response.headers.items()
return self.urllib3_response.getheaders()

def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr('headers', self.urllib3_response):
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments to hasattr() are in the wrong order. The correct signature is hasattr(object, name), but this code has hasattr('headers', self.urllib3_response) which checks if the string 'headers' has an attribute named self.urllib3_response.

This should be:

if hasattr(self.urllib3_response, 'headers'):
Suggested change
if hasattr('headers', self.urllib3_response):
return self.urllib3_response.headers.items()
return self.urllib3_response.getheaders()
def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr('headers', self.urllib3_response):
if hasattr(self.urllib3_response, 'headers'):
return self.urllib3_response.headers.items()
return self.urllib3_response.getheaders()
def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr(self.urllib3_response, 'headers'):

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 50
if hasattr('headers', self.urllib3_response):
return self.urllib3_response.headers.items()
return self.urllib3_response.getheaders()

def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr('headers', self.urllib3_response):
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments to hasattr() are in the wrong order. The correct signature is hasattr(object, name), but this code has hasattr('headers', self.urllib3_response) which checks if the string 'headers' has an attribute named self.urllib3_response.

This should be:

if hasattr(self.urllib3_response, 'headers'):
Suggested change
if hasattr('headers', self.urllib3_response):
return self.urllib3_response.headers.items()
return self.urllib3_response.getheaders()
def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr('headers', self.urllib3_response):
if hasattr(self.urllib3_response, 'headers'):
return self.urllib3_response.headers.items()
return self.urllib3_response.getheaders()
def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr(self.urllib3_response, 'headers'):

Copilot uses AI. Check for mistakes.

def getheader(self, name, default=None):
"""Returns a given response header."""
if hasattr('headers', self.urllib3_response):
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space between if and hasattr. This should be a single space for consistency:

if hasattr(self.urllib3_response, 'headers'):
Suggested change
if hasattr('headers', self.urllib3_response):
if hasattr('headers', self.urllib3_response):

Copilot uses AI. Check for mistakes.
Naman-cell and others added 2 commits December 8, 2025 03:25
…#2418)

- Replace search() with fullmatch() for strict RFC3339 format validation
- Provide clear, actionable error messages with expected format
- Add input whitespace stripping before validation
- Improve exception handling with specific ValueError messages
- Add comprehensive test cases for invalid formats
- Addresses reviewer feedback from PR kubernetes-client#2420

Test: Existing tests pass + new test cases added
add support of `.headers` for urlib3 > 2.0.0
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 8, 2025
@franck-ada franck-ada closed this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/bug Categorizes issue or PR as related to a bug. kind/deprecation Categorizes issue or PR as related to a feature/enhancement marked for deprecation. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getheaders is deprecated in urllib3 >= 2.0.0

3 participants