Describe the bug
Sometimes, the .netrc file is unreadable due to permissions. This is handled in this code:
However, inside the exception handler, this if statement accesses metadata about the path. I assume (but have not yet checked) that netrc_path.is_file() lists metadata of the contents of .netrc's parent directory. This triggers an unchecked exception which, in turn, is not handled by other packages which I'm using.
git blame says the surrounding code is from 5 years ago. I take it this is an edge case, not a new or common issue.
My proposed solution is to warn, but not raise exceptions, if this occurs. This seems to be in spirit with the rest of the code, when the .netrc file is missing.
To Reproduce
I will try to improve on the details here. Preliminary notes:
- Create a system (docker container?) with .netrc in an unreadable directory
- Perform `aiohttp
Expected behavior
I expect aiohttp to warn, but not fail, when .netrc is present. I had no idea aiohttp requires a readable .netrc file and the cloud environment I'm working in does not have one.
Logs/tracebacks
They're unreadable. I will try to make a simple reproduction example.
Python Version
$ python --version
Python 3.8.10
aiohttp Version
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.8.4
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: None
Author-email: None
License: Apache 2
Location: /local_disk0/.ephemeral_nfs/envs/pythonEnv-bcd1c14b-d199-4b6e-9c19-efcc8df3f6e5/lib/python3.8/site-packages
Requires: aiosignal, async-timeout, attrs, yarl, multidict, frozenlist, charset-normalizer
Required-by: adlfs
multidict Version
$ python -m pip show multidict
Name: multidict
Version: 6.0.4
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /local_disk0/.ephemeral_nfs/envs/pythonEnv-bcd1c14b-d199-4b6e-9c19-efcc8df3f6e5/lib/python3.8/site-packages
Requires:
Required-by: yarl, aiohttp
yarl Version
$ python -m pip show yarl
Name: yarl
Version: 1.8.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /local_disk0/.ephemeral_nfs/envs/pythonEnv-bcd1c14b-d199-4b6e-9c19-efcc8df3f6e5/lib/python3.8/site-packages
Requires: multidict, idna
Required-by: aiohttp
OS
I don't quite know, as I am using a hosted cloud environment. Looks Ubuntu linux based:
$ cat /etc/issue
Ubuntu 20.04.5 LTS \n \l
$ uname -a
Linux 0519-075302-a208ww1k-10-177-253-11 5.4.0-1100-azure #106~18.04.1-Ubuntu SMP Mon Dec 12 21:49:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Related component
Client
Additional context
Databricks on MS Azure, inside a notebook, using the adlfs module to access files in Azure Blob Storage.
Code of Conduct
Describe the bug
Sometimes, the
.netrcfile is unreadable due to permissions. This is handled in this code:aiohttp/aiohttp/helpers.py
Line 226 in 6da0469
However, inside the exception handler, this
ifstatement accesses metadata about the path. I assume (but have not yet checked) thatnetrc_path.is_file()lists metadata of the contents of.netrc's parent directory. This triggers an unchecked exception which, in turn, is not handled by other packages which I'm using.git blamesays the surrounding code is from 5 years ago. I take it this is an edge case, not a new or common issue.My proposed solution is to warn, but not raise exceptions, if this occurs. This seems to be in spirit with the rest of the code, when the
.netrcfile is missing.To Reproduce
I will try to improve on the details here. Preliminary notes:
Expected behavior
I expect
aiohttpto warn, but not fail, when.netrcis present. I had no ideaaiohttprequires a readable.netrcfile and the cloud environment I'm working in does not have one.Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
I don't quite know, as I am using a hosted cloud environment. Looks Ubuntu linux based:
Related component
Client
Additional context
Databricks on MS Azure, inside a notebook, using the
adlfsmodule to access files in Azure Blob Storage.Code of Conduct