feat: add SOCKS proxy support via aiohttp-socks ProxyConnector#23798
Open
MagicAbdel wants to merge 2 commits into
Open
feat: add SOCKS proxy support via aiohttp-socks ProxyConnector#23798MagicAbdel wants to merge 2 commits into
MagicAbdel wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache:82">
P2: Configured SOCKS proxy may be conflicted by environment proxy settings because `self.proxy = None` removes the explicit proxy override while `trust_env=True` remains active on the session.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py:82">
P1: Connector instantiated in synchronous `__init__` may fail on aiohttp 3.10+ outside a running event loop</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache:219">
P2: Potential credential disclosure: the ImportError includes the raw proxy URL (`self.proxy`), which may contain embedded credentials (e.g. `socks5://user:pass@host:1080`). This leaks proxy credentials into logs, CI output, or telemetry when aiohttp-socks is missing.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Re-trigger cubic
1393509 to
3c298c2
Compare
Author
|
@cubic-dev-ai comments addressed |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #23797
This PR adds SOCKS proxy support to the asyncio Python client template.
When a kubeconfig cluster entry contains a
proxy-urlwith a SOCKSscheme (e.g.
socks5://localhost:1080), the async client currentlyfails with:
This happens because
aiohttp.TCPConnectordoes not support SOCKSschemes at the request level — a dedicated
ProxyConnectorfromaiohttp-socksis required at the session level instead.Changes
modules/openapi-generator/src/main/resources/python-asyncio/rest.mustacheSUPPORTED_SOCKS_PROXIESfrozenset constant for the four SOCKSschemes (
socks4,socks4a,socks5,socks5h)partition("://")— no extra dependenciesaiohttp_socks.ProxyConnectorinstead ofaiohttp.TCPConnectorProxyConnectorso non-SOCKS users are unaffectedself.proxy = Nonewhen using SOCKS connector to avoid doubleproxy application per-request
Notes
socks4,socks4a,socks5,socks5haiohttp>=3.10.0andaiohttp-socks>=0.9.0aiohttp-socksis neverimported unless a SOCKS proxy URL is configured
aiohttp-socksinstalled willreceive a clear
ImportErrorinstead of the previous crypticServerDisconnectedErrorself.proxyis set toNonewhen usingProxyConnectorto avoiddouble proxy application — the connector handles routing at the
connection level, not per-request
PR checklist
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Add SOCKS proxy support to the asyncio Python client via
aiohttp-socksProxyConnector, fixing failures whenproxy-urlusessocks*schemes. Fixes #23797.New Features
socks4,socks4a,socks5,socks5hvia session-levelProxyConnector.from_urlwithtrust_env=True; HTTP/HTTPS path unchanged; requiresaiohttp-socks>=0.9.0.socks*and create theaiohttpClientSessionwithProxyConnectorvsTCPConnector; for SOCKS, disable per-requestproxy/proxy_headers.Refactors
partition("://")and afrozensetfor SOCKS detection; updated generated samples.Written for commit 8808735. Summary will update on new commits. Review in cubic