question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

repository credential resolution from config is ambiguous

See original GitHub issue
  • 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).

  • Poetry 1.1.4

Issue

As a practical example, gitlab provides public/private package registries on projects which follow the general url form: https://gitlab.com/api/v4/projects/<project id>/packages/pypi/simple.

Let’s say a user is part of two separate (private) projects on gitlab, foo and bar, and they configure poetry on their system as follows:

poetry config repositories.foo-pypi "https://gitlab.com/api/v4/projects/foo/packages/pypi/simple"
poetry config http-basic.foo-pypi "foo-username" "foo-password"
poetry config repositories.bar-pypi "https://gitlab.com/api/v4/projects/bar/packages/pypi/simple"
poetry config http-basic.bar-pypi "bar-username" "bar-password"

In project baz they have the following dependency

[tool.poetry.dependencies]
bar-library = {version = "^1.0.0", source = "bar-pypi"}

When poetry goes to look up bar-library, it will try to use the foo-username and foo-password credentials, which will fail as these are the wrong credentials (this is somewhat heinous in gitlab’s case, as it just replies with a 404 on bad credentials, I believe to avoid leaking information about private resources. The 404 just looks like a missing package to poetry rather than a credential error, so it ends up erroring in the solver).

The reason the wrong credentials are used is in poetry/installation/authenticator.py, specifically in Authenticator._get_credentials_for_netloc_from_config. The problem is that poetry does a credential lookup based on the netloc component of the parsed repository URL (in this case, gitlab.com) and it compares it to the netloc component of each repository URL in the config until it finds a match. Because both of the configured repositories have the same netloc in their URL, the credentials for the first one stored in the configuration file will always be used.

I suspect an appropriate fix would involve passing the repository name through to the authenticator (when available) rather than performing the potentially lossy process of name -> url -> name that is currently used.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
glencairncommented, Dec 11, 2020

I couldn’t find anything in the documentation about the source field. I think that’s a neat feature that should definitely be captured in the docs. I’ll write a quick PR.

2reactions
glencairncommented, Dec 11, 2020

version 1.1.4 advertises the --source option for the poetry add command- I think it’s safe to say this is a supported feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learning the Basics - Gradle User Manual
You can specify credentials for Maven repositories secured by different type ... by resolution context: configuration name or even configuration attributes.
Read more >
Manage Credentials with ASK CLI | Alexa Skills Kit
Learn how the ASK CLI stores and manages your credentials for Amazon developer services and Amazon Web Services (AWS).
Read more >
How to Identify and Resolve Ambiguous CIs - TechDocs
Select the CI that you want to remove from ambiguity management from the Ambiguous CI List page. The Configuration Item Detail page appears....
Read more >
git - Sourcetree for Mac - Can no longer pull code and error ...
I tried to pull code utilizing Sourcetree from a repository I had ... -c credential.helper=sourcetree fetch origin Completed with errors, ...
Read more >
Upgrading to Serverless Framework v3
Feel free to open an issue or pull request in the GitHub repository of the plugin. ... Some edge cases (ambiguous configuration) now...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found