-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
aiohttp == 3.12.14
python==3.10.12
ClientSession._request
elif self._trust_env:
with suppress(LookupError):
proxy_, proxy_auth = await asyncio.to_thread(
get_env_proxy_for_url, url
)
This LookupError is raising an exception despite the suppress
. Observed when using azure blob storage:
azure-core==1.35.0
azure-identity==1.23.1
azure-storage-blob==12.26.0
As far as I can tell, the LookupError is the builtin Python exception and azure lib is not touching anything there, except passing in trust_env = True
.
Additionally, I don't think that should cause any issues here, but this is currently occurring in asyncio Tasks that are awaited and collected.
The workaround for me right now is to patch ClientSession usage in azure lib to pass trust_env=False
To Reproduce
azure-core==1.35.0
azure-identity==1.23.1
azure-storage-blob==12.26.0
aiohttp == 3.12.14
Using the Azure BlobServiceClient:
client: BlobServiceClient = BlobServiceClient(
account_url=...,
credential=...,
)
async with client:
blob_client = client.get_blob_client(container=..., blob="path/to/blob")
stream = await blob_client.download_blob()
print(await stream.readall())
Expected behavior
LookupError
should be raised in the get_env_proxy_for_url
call but be suppressed in ClientSession logic in the suppress
context manager. The request should continue without a proxy.
Logs/tracebacks
File "/venv/.venv/lib/python3.10/site-packages/aiohttp/helpers.py", line 307, in get_env_proxy_for_url
raise LookupError(f"No proxies found for `{url!s}` in the env")
Python Version
$ python --version
3.10.12
aiohttp Version
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.12.14
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author:
Author-email:
License: Apache-2.0
Location: /venv/.venv/lib/python3.10/site-packages
Requires: aiohappyeyeballs, aiosignal, async-timeout, attrs, frozenlist, multidict, propcache, yarl
Required-by: aiobotocore, indicodata-indicore, indicodata-spyglass
multidict Version
$ python -m pip show multidict
Name: multidict
Version: 6.6.3
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache License 2.0
Location: /venv/.venv/lib/python3.10/site-packages
Requires: typing-extensions
Required-by: aiobotocore, aiohttp, yarl
propcache Version
$ python -m pip show propcache
Name: propcache
Version: 0.3.2
Summary: Accelerated property cache
Home-page: https://github.com/aio-libs/propcache
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Location: /venv/.venv/lib/python3.10/site-packages
Requires:
Required-by: aiohttp, yarl
yarl Version
$ python -m pip show yarl
Name: yarl
Version: 1.20.1
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Location: /venv/.venv/lib/python3.10/site-packages
Requires: idna, multidict, propcache
Required-by: aiohttp
OS
PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
Related component
Client
Additional context
This is running in an AKS cluster in an Ubuntu container with the above versions. There are no proxies set up in the environment.
Code of Conduct
- I agree to follow the aio-libs Code of Conduct