requests: Poetry cannot publish artifacts anymore due to auto update to requests 2.30.0
When doing a publish of an artifact with poetry, it suddenly starts failing due to requests 2.30.0.
poetry publish -vvv -r $REPOSITRY -u $USERNAME -p $PASSWORD
Expected Result
The artifact build in poetry get’s published on artifactory.
Loading configuration file /opt/app-root/.config/pypoetry/config.toml
Adding repository default-pypi (https://artifactory/artifactory/api/pypi/pypi/simple) and setting it as the default one
Adding repository my-pypi (https://artifactory/artifactory/api/pypi/my-pypi/simple) and setting it as secondary
Deactivating the PyPI repository
Publishing my_artifact (0.2.0) to artifactory
- Uploading my_artifact-0.2.0-py3-none-any.whl 0%[urllib3.connectionpool] Starting new HTTPS connection (1): artifactory:443
- Uploading my_artifact-0.2.0-py3-none-any.whl 100%[urllib3.connectionpool] https://artifactory:443 "POST /artifactory/api/pypi/my-pypi HTTP/1.1" 200 0
- Uploading my_artifact-0.2.0.tar.gz 0%
- Uploading my_artifact-0.2.0.tar.gz 100%[urllib3.connectionpool] https://artifactory:443 "POST /artifactory/api/pypi/my-pypi HTTP/1.1" 200 0
Actual Result
‘poetry install -vv Using virtualenv: /opt/app-root Installing dependencies from lock file Finding the necessary packages for the current system Package operations: 59 installs, 3 updates, 0 removals, 11 skipped • Installing markupsafe (2.1.2) • Installing pyparsing (3.0.9) • Installing sniffio (1.3.0) • Updating urllib3 (1.26.15 -> 2.0.2) • Installing alabaster (0.7.13) • Installing anyio (3.6.2) • Installing babel (2.12.1) • Installing docutils (0.17.1) • Installing exceptiongroup (1.1.1) • Installing h11 (0.14.0) • Installing imagesize (1.4.1) • Installing iniconfig (2.0.0) • Installing jinja2 (3.1.2) • Installing lazy-object-proxy (1.9.0) • Installing mccabe (0.6.1) • Installing pluggy (1.0.0) • Installing pycodestyle (2.7.0) • Installing pydot (1.4.2) • Installing pyflakes (2.3.1) • Installing pygments (2.15.1) • Updating requests (2.29.0 -> 2.30.0) • Installing snowballstemmer (2.2.0) • Installing sphinxcontrib-applehelp (1.0.4) • Installing sphinxcontrib-devhelp (1.0.2) • Installing sphinxcontrib-htmlhelp (2.0.1) • Installing sphinxcontrib-jsmath (1.0.1) • Installing sphinxcontrib-qthelp (1.0.3) • Installing sphinxcontrib-serializinghtml (1.1.5) • Installing typing-extensions (4.5.0) • Installing wrapt (1.15.0) [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 • Installing astmonkey (0.3.6) • Installing astroid (2.15.4) • Installing click (8.1.3) • Installing coverage (6.5.0) • Installing dill (0.3.6) • Installing flake8 (3.9.2) • Installing httpcore (0.17.0) • Installing isort (5.12.0) • Installing mypy-extensions (1.0.0) • Installing pathspec (0.11.1) • Updating platformdirs (2.6.2 -> 3.5.0) • Installing pytest (7.3.1) • Installing pyyaml (6.0) • Installing sphinx (4.5.0) • Installing termcolor (2.3.0) [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 [urllib3.connectionpool] Connection pool is full, discarding connection: artifactory. Connection pool size: 10 • Installing assertpy (1.1) • Installing black (22.3.0) • Installing bump2version (1.0.1): Skipped for the following reason: Already installed • Installing certifi (2022.12.7): Skipped for the following reason: Already installed • Installing charset-normalizer (3.1.0): Skipped for the following reason: Already installed • Installing gitchangelog (3.0.4): Skipped for the following reason: Already installed • Installing httpx (0.24.0) • Installing ict-utils (0.1.1) • Installing idna (3.4): Skipped for the following reason: Already installed • Installing importlib-metadata (6.6.0): Skipped for the following reason: Already installed • Installing invoke (1.7.3) • Installing mockito (1.4.0) • Installing mutpy (0.6.1) • Installing mypy (0.971) • Installing nose2 (0.12.0) • Installing packaging (23.1): Skipped for the following reason: Already installed • Installing pallets-sphinx-themes (2.1.0) • Installing ping3 (2.9.3) • Installing pylint (2.17.3) • Installing pyproject-flake8 (0.0.1a5) • Installing pystache (0.6.0): Skipped for the following reason: Already installed • Installing pytest-cov (3.0.0) • Installing pytest-sugar (0.9.7) • Installing tomli (2.0.1): Skipped for the following reason: Already installed • Installing tomlkit (0.11.8): Skipped for the following reason: Already installed • Installing types-six (1.16.21.8) • Installing zipp (3.15.0): Skipped for the following reason: Already installed Connection pool is full, discarding connection: artifactory. Connection pool size: 10 Connection pool is full, discarding connection: artifactory. Connection pool size: 10 Connection pool is full, discarding connection: artifactory. Connection pool size: 10 Connection pool is full, discarding connection: artifactory. Connection pool size: 10 Connection pool is full, discarding connection: artifactory. Connection pool size: 10 Warning: The file chosen for install of requests 2.30.0 (requests-2.30.0-py3-none-any.whl) is yanked. Reason for being yanked: Broken responses when reading compressed content through urllib3 Installing the current project:my_artifact (0.2.0) ImportError cannot import name ‘appengine’ from ‘requests.packages.urllib3.contrib’ (/opt/app-root/lib64/python3.9/site-packages/urllib3/contrib/init.py) at /opt/app-root/lib64/python3.9/site-packages/requests_toolbelt/_compat.py:48 in <module> 44│ if requests.build < 0x021000: 45│ gaecontrib = None 46│ else: 47│ try: → 48│ from requests.packages.urllib3.contrib import appengine as gaecontrib 49│ except ImportError: 50│ from urllib3.contrib import appengine as gaecontrib 51│ 52│ PY3 = sys.version_info > (3, 0) The following error occurred when trying to handle this error: Stack trace: 14 /opt/app-root/lib64/python3.9/site-packages/cleo/application.py:327 in run 325│ 326│ try: → 327│ exit_code = self._run(io) 328│ except BrokenPipeError: 329│ # If we are piped to another process, it may close early and send a 13 /opt/app-root/lib64/python3.9/site-packages/poetry/console/application.py:190 in _run 188│ self._load_plugins(io) 189│ → 190│ exit_code: int = super()._run(io) 191│ return exit_code 192│ 12 /opt/app-root/lib64/python3.9/site-packages/cleo/application.py:431 in _run 429│ io.input.interactive(interactive) 430│ → 431│ exit_code = self._run_command(command, io) 432│ self._running_command = None 433│ 11 /opt/app-root/lib64/python3.9/site-packages/cleo/application.py:473 in _run_command 471│ 472│ if error is not None: → 473│ raise error 474│ 475│ return terminate_event.exit_code 10 /opt/app-root/lib64/python3.9/site-packages/cleo/application.py:457 in _run_command 455│ 456│ if command_event.command_should_run(): → 457│ exit_code = command.run(io) 458│ else: 459│ exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED 9 /opt/app-root/lib64/python3.9/site-packages/cleo/commands/base_command.py:119 in run 117│ io.input.validate() 118│ → 119│ status_code = self.execute(io) 120│ 121│ if status_code is None: 8 /opt/app-root/lib64/python3.9/site-packages/cleo/commands/command.py:62 in execute 60│ 61│ try: → 62│ return self.handle() 63│ except KeyboardInterrupt: 64│ return 1 7 /opt/app-root/lib64/python3.9/site-packages/poetry/console/commands/publish.py:50 in handle 48│ 49│ def handle(self) -> int: → 50│ from poetry.publishing.publisher import Publisher 51│ 52│ publisher = Publisher(self.poetry, self.io) 6 /opt/app-root/lib64/python3.9/site-packages/poetry/publishing/init.py:3 in <module> 1│ from future import annotations 2│ → 3│ from poetry.publishing.publisher import Publisher 4│ 5│ 5 /opt/app-root/lib64/python3.9/site-packages/poetry/publishing/publisher.py:7 in <module> 5│ from typing import TYPE_CHECKING 6│ → 7│ from poetry.publishing.uploader import Uploader 8│ from poetry.utils.authenticator import Authenticator 9│ 4 /opt/app-root/lib64/python3.9/site-packages/poetry/publishing/uploader.py:17 in <module> 15│ from requests.exceptions import ConnectionError 16│ from requests.exceptions import HTTPError → 17│ from requests_toolbelt import user_agent 18│ from requests_toolbelt.multipart import MultipartEncoder 19│ from requests_toolbelt.multipart import MultipartEncoderMonitor 3 /opt/app-root/lib64/python3.9/site-packages/requests_toolbelt/init.py:12 in <module> 10│ “”" 11│ → 12│ from .adapters import SSLAdapter, SourceAddressAdapter 13│ from .auth.guess import GuessAuth 14│ from .multipart import ( 2 /opt/app-root/lib64/python3.9/site-packages/requests_toolbelt/adapters/init.py:12 in <module> 10│ “”" 11│ → 12│ from .ssl import SSLAdapter 13│ from .source import SourceAddressAdapter 14│ 1 /opt/app-root/lib64/python3.9/site-packages/requests_toolbelt/adapters/ssl.py:16 in <module> 14│ from requests.adapters import HTTPAdapter 15│ → 16│ from …_compat import poolmanager 17│ 18│ ImportError cannot import name ‘appengine’ from ‘urllib3.contrib’ (/opt/app-root/lib64/python3.9/site-packages/urllib3/contrib/init.py) at /opt/app-root/lib64/python3.9/site-packages/requests_toolbelt/_compat.py:50 in <module> 46│ else: 47│ try: 48│ from requests.packages.urllib3.contrib import appengine as gaecontrib 49│ except ImportError: → 50│ from urllib3.contrib import appengine as gaecontrib 51│ 52│ PY3 = sys.version_info > (3, 0) 53│ 54│ if PY3: Cleaning up project directory and file based variables 00:00 ERROR: Job failed: command terminated with exit code 1’
Reproduction Steps
poetry publish -vvv -r $REPOSITRY -u $USERNAME -p $PASSWORD
Workaorund
Define request dependency in the poetry pyproject.toml file to take any version higher than 2.28.2 except the yanked 2.30.0, you can do this as follow:
requests = "^2.28.2, !=2.30.0"
System Information
- python 3.9
- requests 2.30.0
- poetry 1.4.2
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Add requests to fix error while uploading - https://github.com/psf/requests/issues/6441 — committed to ucyo/imk-toolkit by ucyo a year ago
I’m getting the same error with requests- 2.31.0
requests 2.31.0 seems fine
and as long as i pin
urllib3to1.26.x, versions ofrequestsandrequests-toolbeltdon’t matter 🤔In my case it didn’t solve the issue even when it uses the latest request library I think it has to be fixed in poetry also but not sure…
Two comments above yours explains the problem: https://github.com/psf/requests/issues/6441#issuecomment-1534752003
Hi there, I have the exact same issue here.