Skip to content

Fix: properly load and parse NO_PROXY environment variable#2523

Open
Ndugu2 wants to merge 1 commit intokubernetes-client:masterfrom
Ndugu2:fix-no-proxy-2520
Open

Fix: properly load and parse NO_PROXY environment variable#2523
Ndugu2 wants to merge 1 commit intokubernetes-client:masterfrom
Ndugu2:fix-no-proxy-2520

Conversation

@Ndugu2
Copy link

@Ndugu2 Ndugu2 commented Mar 13, 2026

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes the handling of the NO_PROXY environment variable in the Configuration class. Previously:

  1. No parsing: The value was stored as a raw string instead of being parsed into a list of domains
  2. Precedence issues: When both NO_PROXY and no_proxy were set, the lowercase version could take precedence incorrectly
  3. Empty string handling: An empty NO_PROXY="" was treated the same as if the variable wasn't set
  4. Default value: self.no_proxy defaulted to None instead of an empty list

These issues caused proxy bypass settings to be ignored, breaking functionality for users relying on no_proxy configurations.

Which issue(s) this PR fixes:

Fixes #2520

Special notes for your reviewer:

The fix implements proper precedence checking using in os.environ rather than os.getenv() to correctly detect when a variable exists even if it's empty. The value is now parsed into a list of domains with whitespace stripped.

Test cases added cover:

  • Uppercase NO_PROXY
  • Lowercase no_proxy
  • Both uppercase and lowercase (precedence test)
  • Empty string values
  • No environment variable set
  • Spaces in comma-separated values

Does this PR introduce a user-facing change?

Fixed: The NO_PROXY environment variable is now properly parsed into a list of domains. Uppercase NO_PROXY correctly takes precedence over lowercase no_proxy. Empty NO_PROXY="" now results in an empty list rather than falling back to the lowercase variant.

Signed-off-by: Kosea Kalema <koseakalema2@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Mar 13, 2026
@k8s-ci-robot k8s-ci-robot requested a review from roycaihw March 13, 2026 08:19
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ndugu2
Once this PR has been reviewed and has the lgtm label, please assign yliaog 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

@k8s-ci-robot k8s-ci-robot requested a review from yliaog March 13, 2026 08:19
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 13, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Ndugu2 / name: Kosea Kalema (e78a303)

@k8s-ci-robot
Copy link
Contributor

Welcome @Ndugu2!

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 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. 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 Mar 13, 2026
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. kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no_proxy environment variable ignored in kubernetes-client Python library

2 participants