python-poetry / python-poetry/poetry

poetry not trying secondary source if default source is offline

Open
#6,010 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

I've been trying to setup poetry such that it tries to retrieve packages from a private server first, and should that fail, it uses the public PyPi server as a backup. This is how my sources are configured:

[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/"
default = true
secondary = false

[[tool.poetry.source]]
name = 'pypi-public'
url = 'https://pypi.python.org/simple'
default = false
secondary = true

To test this I tried to install a common python package (pandas), but I get an error that a connection cannot be established to foo.bar:

$ poetry add pandas                                                                                                                                     

  ConnectionError

  HTTPSConnectionPool(host='foo.bar', port=443): Max retries exceeded with url: /simple/pandas/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x10266dfc0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))

  at /opt/homebrew/Cellar/poetry/1.1.14/libexec/lib/python3.10/site-packages/requests/adapters.py:565 in send
      561│             if isinstance(e.reason, _SSLError):
      562│                 # This branch is for urllib3 v1.22 and later.
      563│                 raise SSLError(e, request=request)
      564│
    → 565│             raise ConnectionError(e, request=request)
      566│
      567│         except ClosedPoolError as e:
      568│             raise ConnectionError(e, request=request)

The fact that it can't establish a connection to foo.bar of course makes sense, but what I don't understand why it isn't even trying to use the public PyPi source I specified as secondary.

Is this an actual bug or am I misunderstanding the intended behavior of poetry? I would think (intuitively) that poetry would try use a secondary source if the default is unavailable (.e.g, it's down for maintenance).

How can I go about configuring poetry to behave in the way I had hoped it to? (trying my private source first, and then falling back to the public PyPi source).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the provided source configuration and the offline foo.bar endpoint, then inspect Poetry's package source selection and connection-error handling. Done means a failed default source allows resolution from the configured secondary PyPI source, with tests covering the fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.