Skip to content

[python] honor proxy environment settings#24082

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
tamird:codex/python-proxy-environment
Jun 23, 2026
Merged

[python] honor proxy environment settings#24082
wing328 merged 1 commit into
OpenAPITools:masterfrom
tamird:codex/python-proxy-environment

Conversation

@tamird

@tamird tamird commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

The default urllib3 client does not read proxy environment variables,
so generated clients require users to copy them into
Configuration.proxy. 97e079f added no_proxy handling, but
01ed597 replaced the Python templates without carrying it forward.

Read scheme-specific proxies and no_proxy from the standard library's
environment proxy configuration. Explicit empty values remain opt-outs,
and bypass matching covers domains, ports, IPv4 CIDRs, and IPv6 CIDRs
without adding requests as a generated dependency.

This is limited to the synchronous urllib3 client. The async backends
have separate proxy implementations.

Fixes #6786.
Partially addresses #20226.

@tamird tamird marked this pull request as ready for review June 21, 2026 15:45

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread samples/openapi3/client/petstore/python/petstore_api/configuration.py Outdated
@tamird tamird force-pushed the codex/python-proxy-environment branch 2 times, most recently from 139d8fc to e64974b Compare June 21, 2026 15:56
@tamird

tamird commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@wing328 @multani, could one of you review this Python client generator fix? It restores proxy-environment handling in the configuration and REST templates you maintain or have reviewed, while preserving explicit Configuration.proxy and no_proxy overrides. Cubic is clean and CI is green.

@tamird tamird force-pushed the codex/python-proxy-environment branch 2 times, most recently from 02bf7e7 to d79e860 Compare June 21, 2026 16:22
@wing328

wing328 commented Jun 22, 2026

Copy link
Copy Markdown
Member

thanks for the PR

cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)

@wing328 wing328 added this to the 7.24.0 milestone Jun 22, 2026
@tamird tamird force-pushed the codex/python-proxy-environment branch from d79e860 to 0fb5275 Compare June 22, 2026 09:59
@tamird

tamird commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Updated to regenerate all the other samples.

@tamird

tamird commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Sent #24092 to fix the unrelated failures which seem to date back to 2023.

@wing328

wing328 commented Jun 22, 2026

Copy link
Copy Markdown
Member

merged those. please update this PR with the latest master when you've time

@tamird tamird force-pushed the codex/python-proxy-environment branch from 0fb5275 to ae4ea4f Compare June 22, 2026 14:54
@tamird

tamird commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

merged those. please update this PR with the latest master when you've time

Done.

Comment thread modules/openapi-generator/src/main/resources/python/rest.mustache
@tamird tamird force-pushed the codex/python-proxy-environment branch from ae4ea4f to 5324086 Compare June 23, 2026 10:45
urllib3 does not read proxy environment variables, so generated clients
require users to copy them into Configuration.proxy. 97e079f added
no_proxy handling, but 01ed597 replaced the Python templates without
carrying it forward.

Resolve scheme-specific proxy and no-proxy defaults through
urllib.request while preserving explicit empty values as opt-outs.
Match domain, port, IPv4 CIDR, and IPv6 CIDR bypass entries without
adding requests to generated clients.
@tamird tamird force-pushed the codex/python-proxy-environment branch from 5324086 to 4d74f03 Compare June 23, 2026 10:59
@wing328 wing328 merged commit 62bfb06 into OpenAPITools:master Jun 23, 2026
47 of 49 checks passed
@tamird tamird deleted the codex/python-proxy-environment branch June 23, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] Add proxy support via environment variables

2 participants