poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Poetry config reports wrong error message when missing values for `poetry config http-basic`

Open Kircheneer opened this issue 3 years ago • 5 comments

  • Poetry version: 1.2.2
  • Python version: 3.9.2
  • OS version and name:Debian GNU/Linux 11 (bullseye)
  • pyproject.toml: Default config after poetry init - see below
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Leo Kirchner <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
  • [x] I am on the latest stable Poetry version, installed using a recommended method.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I think the error message for missing credentials in this command could be a little more precise:

$ poetry config http-basic.foo

There is no http-basic.foo setting.

This is especially relevant when using environment variables inside a DOCKERFILE where the variables may be (accidentally) undefined:

$ poetry config http-basic.foo $FOO_NAME $FOO_PASSWORD

There is no http-basic.foo setting.

Kircheneer avatar Oct 28 '22 08:10 Kircheneer

I've also run into the same problem:while installing Poetry inside a Dockerfile.

RUN poetry source add --secondary myrepo https://pypi.myrepo.com/simple/ && \
    poetry config http-basic.myrepo $POETRY_HTTP_BASIC_PYPI_USERNAME $POETRY_HTTP_BASIC_PYPI_PASSWORD
...
 ---> Running in fe4e7ecce71d
Source with name myrepo already exists. Skipping addition.

There is no http-basic.myrepo setting.

I've added the source two times to make sure that the setting would be there, and still haven't got it to work properly. I'm in Poetry 1.3.1.

ftadao avatar Dec 15 '22 12:12 ftadao

Update: the error is not that the setting doesn't exist, it was that the environment variables that I was passing were empty. The error message is misleading. IIRC I saw one ticket that was related to that specific error message around.

@Kircheneer check what's inside your $FOO_NAME and $FOO_PASSWORD variables.

ftadao avatar Dec 15 '22 14:12 ftadao

Thank you @ftadao - I had already identified this and it is what I meant to convey with the last part of my original issue.

Kircheneer avatar Dec 15 '22 14:12 Kircheneer

Oh, sorry! I was thinking that I was posting on another issue related to the error itself. Kinda got a little repetitive there :sweat_smile:

ftadao avatar Dec 15 '22 14:12 ftadao

Encountered this today, and decided to skim into the source to find out the cause. I think this could be easily fixed by modifying here - https://github.com/python-poetry/poetry/blob/cdfd955144204c25b277309007c332aaee8be28c/src/poetry/utils/password_manager.py#L200, and not returning an empty HTTPAuthCredential if the username is not found.

I'd like to attempt a fix for this. Could one of the maintainers let me know if I have the right culprit?

ritabratam-ciq avatar Dec 02 '24 08:12 ritabratam-ciq

@ritabratam-ciq I think your issue might be fixed in #10088. This issue however, seems to be about the error message of the config command.

The comments otherwise are a bit misleading and pointing to another issue (empty or missing password).

abn avatar Jan 26 '25 22:01 abn