Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using urllib3 2.x.x release #70

Open
cquike opened this issue May 26, 2023 · 7 comments
Open

Error when using urllib3 2.x.x release #70

cquike opened this issue May 26, 2023 · 7 comments

Comments

@cquike
Copy link

cquike commented May 26, 2023

I am trying to run a requests with a UNIX socket but it fails using the latest versions in PyPI. I guess it is related to the change in major version of urllib3 2.0.0 that happened in PyPI roughly 1 month ago

$ python3 -m venv  my_venv
(my_venv) $  . ./my_venv/bin/activate
(my_venv) $ pip install requests-unixsocket
Collecting requests-unixsocket
  Using cached requests_unixsocket-0.3.0-py2.py3-none-any.whl (11 kB)
Collecting requests>=1.1
  Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting charset-normalizer<4,>=2
  Using cached charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (197 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1
  Using cached urllib3-2.0.2-py3-none-any.whl (123 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 kB 1.5 MB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests, requests-unixsocket
Successfully installed certifi-2023.5.7 charset-normalizer-3.1.0 idna-3.4 requests-2.31.0 requests-unixsocket-0.3.0 urllib3-2.0.2

[notice] A new release of pip available: 22.3.1 -> 23.1.2
[notice] To update, run: pip install --upgrade pip

(my_venv) $ cat test.py
import requests
import requests_unixsocket
requests_unixsocket.monkeypatch()
requests.get('http+unix://%2Frun%2Fuser%2F4876%2Fadari_server_834977.socket')
(my_venv) $ python3 test.py
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests_unixsocket/__init__.py", line 51, in get
    return request('get', url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests_unixsocket/__init__.py", line 46, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/my_venv/lib64/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'
@cquike
Copy link
Author

cquike commented May 26, 2023

If urllib3 is downgraded to 1.26.16 then the problem disappears.

@webknjaz
Copy link

We also get the same error: https://github.com/cherrypy/cheroot/actions/runs/5107356552/jobs/9190603385#step:19:941 — I suppose this project needs to be adapted to make use of the new API.

@webknjaz
Copy link

Oh, it looks like #69 might address this problem.

@webknjaz
Copy link

@msabramo could you help to get the fix for this released? It's affecting many project CIs now due to the underlying urllib3 update to v2.

mupuf added a commit to mupuf/requests-unixsocket that referenced this issue May 30, 2023
By inheriting from `urllib3.connection.HTTPConnection` (that inherits
from `httplib.HTTPConnection` itself), we can adapt to the internal
changes in urllib3 2.0 that added a `request()` method that is
incompatible with httplib.HTTPConnection.request.

This fixes the incompatibility between urllib3 2.0 and requests 1.26+,
which was the first version that stopped vendoring urllib3.

Reference: docker/docker-py#3113 (comment)
Fixes: msabramo#70
mupuf added a commit to mupuf/requests-unixsocket that referenced this issue May 30, 2023
By inheriting from `urllib3.connection.HTTPConnection` (that inherits
from `httplib.HTTPConnection` itself), we can adapt to the internal
changes in urllib3 2.0 that added a `request()` method that is
incompatible with httplib.HTTPConnection.request.

This fixes the incompatibility between urllib3 2.0 and requests 1.26+,
which was the first version that stopped vendoring urllib3.

Reference: docker/docker-py#3113 (comment)
Fixes: msabramo#70
webknjaz added a commit to cherrypy/cheroot that referenced this issue Jul 2, 2023
This is needed because `requests-unixsocket` is currently incompatible
with the new release stream of `urllib3`[[1]] and it's unclear how
long it will take to get the bugfix PR[[2]] merged and a release
published.

[1]: msabramo/requests-unixsocket#70
[2]: msabramo/requests-unixsocket#69
@crgwbr
Copy link

crgwbr commented May 22, 2024

FYI to all: since this project seems to be abandoned, but its longevity is important to my team, we've forked the project as requests-unixsocket2. It should be a drop in replacement for this package.

We've migrated the fix for this issue there, merged it, and released to PyPI as part of v0.4.0.

@cquike
Copy link
Author

cquike commented Jul 2, 2024

@crgwbr : do you plan to eventually take over the requests-unixsocket pypi place now that the original requests-unixsocket is abandoneware? I have no idea whether that's possible, I don't know the policiess for pypi.

@cquike
Copy link
Author

cquike commented Jul 2, 2024

@crgwbr : do you plan to eventually take over the requests-unixsocket pypi place now that the original requests-unixsocket is abandoneware? I have no idea whether that's possible, I don't know the policiess for pypi.

Oh sorry, I realize this has already been asked in #69. In any case I just wanted to thank you @crgwbr for moving this forward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants