python-poetry / python-poetry/poetry
poetry stores repo credentials by host, it should include path
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
if you have multiple pypi repositories off the same domain but with different paths, poetry will fail to authenticate properly because it will store the credentials for the repository based on the domain, but not inclusive of path, meaning it will use the wrong credentials for a given domain.
tldr poetry credential cache keys are not correct per python spec on pypi, as poetry doesn't address repositories by suffix.
https://www.python.org/dev/peps/pep-0503/
separately there's an issue is that the url doesn't get normalized early, so subsequent lookups in different parts of the codebase but same cli exec will do lookups with and without + 'simple' on the url.
- [ x ] I am on the latest Poetry version.
- [ x ] I have searched the issues of this repo and believe that this is not a duplicate.
- [ x ] If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
$ poetry config --list | grep repo
repositories.assetdb.url = "https://corp-1122334455.d.codeartifact.us-east-1.amazonaws.com/pypi/assetdb/"
repositories.c7n-next.url = "https://corp-1122334455.d.codeartifact.us-east-1.amazonaws.com/pypi/c7n/"
traceback
• Installing c7n (0.1.2): Pending...
• Installing c7n (0.1.2): Failed
RepositoryError
401 Client Error: Unauthorized for url: https://corp-1122334455.d.codeartifact.us-east-1.amazonaws.com/pypi/c7n/simple/c7n/
at ~/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/repositories/legacy_repository.py:393 in _get
389│ if response.status_code == 404:
390│ return
391│ response.raise_for_status()
392│ except requests.HTTPError as e:
→ 393│ raise RepositoryError(e)
394│
395│ if response.status_code in (401, 403):
396│ self._log(
397│ "Authorization error accessing {url}".format(url=response.url),
Versions
- Linux/Ubuntu 20.04
- Poetry 1.12
The underlying issue appears to be how credentials are retrieved, it simply grabs the credentials for the first repository that has a domain match
https://github.com/python-poetry/poetry/blob/master/src/poetry/utils/authenticator.py#L151
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/poetry/utils/authenticator.py around the credential lookup at line 151, then inspect the request flow in legacy_repository.py around _get. Compare repository URL handling with PEP 503, including the differing /simple/ forms. Done means repositories sharing a host use credentials keyed by their paths and lookups behave consistently within one CLI run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100