Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing configuration for http auth (environment variables) #1871

Closed
3 tasks done
fralik opened this issue Jan 11, 2020 · 6 comments
Closed
3 tasks done

Processing configuration for http auth (environment variables) #1871

fralik opened this issue Jan 11, 2020 · 6 comments
Labels
kind/bug Something isn't working as expected

Comments

@fralik
Copy link

fralik commented Jan 11, 2020

  • 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).

  • OS version and name: Windows 10, 64-bit.

  • Poetry version: 1.0.2

Issue

Documentation says that any config value can be passed through an environment variable POETRY_<config> as well as secrets for private repos. However, I suspect that the code doesn't process secrets correctly.

Setup:

  1. There is no auth.toml file.
  2. Url for the private repo is added in config.toml.
  3. pyproject.toml contains url and name for the same private repo.
  4. pyproject.toml references one package from the private repo.
  5. Variables POETRY_HTTP_BASIC_REPO_PASSWORD and POETRY_HTTP_BASIC_REPO_USERNAME are set.
  6. Variable POETRY_HTTP_BASIC_REPO is not set.
  7. Some debug output (print) is added to poetry source code.

Outcome:

>poetry install --dry-run --no-ansi -vvv                                                                        
Getting auth for repo
Need to get setting http-basic.repo
Checking variable POETRY_HTTP_BASIC_REPO, value <object object at 0x00000239FFCD5900>, not set <object object at 0x00000239FFCD5900>
Value is not set, so continue
Checking key: http-basic
Will return default: None
Failed to get auth                                                                                                                                            
Using virtualenv: c:\home\anaconda3\envs\env-poetry                                                                                                           
Updating dependencies                                                                                                                                         
Resolving dependencies...                                                                                                                                     
   1: fact: demo is 0.1.0                                                                                                                           
   1: derived: demo                                                                                                                                 
   1: fact: demo depends on treeview (~0.1.0)                                                                                                       
   1: selecting demo (0.1.0)                                                                                                                        
   1: derived: treeview (~0.1.0)                                                                                                                              
   1: fact: no versions of treeview match >=0.1.0,<0.2.0                                                                                                      
   1: conflict: no versions of treeview match >=0.1.0,<0.2.0                                                                                                  
   1: ! treeview (~0.1.0) is satisfied by treeview (~0.1.0)                                                                                                   
   1: ! which is caused by "demo depends on treeview (~0.1.0)"                                                                                      
   1: ! thus: version solving failed                                                                                                                          
   1: Version solving took 0.348 seconds.                                                                                                                     
   1: Tried 1 solutions.                                                                                                                                      
                                                                                                                                                              
[SolverProblemError]                                                                                                                                          
Because demo depends on treeview (~0.1.0) which doesn't match any versions, version solving failed.

Thoughts:
It looks like get_http_auth expects a dictionary. We can only get a dictionary if we read from the config file, not the environment variable. Or am I wrong here?

I made more experiments around this (like defining POETRY_HTTP_BASIC_REPO with various content), but couldn't get around the fact that auth must be a dictionary.

Variables POETRY_HTTP_BASIC_REPO_USERNAME and POETRY_HTTP_BASIC_REPO_PASSWORD seem never to be read. Only if I reference them with smth like this:

export POETRY_HTTP_BASIC_REPO={http.basic.repo.username} {http.basic.repo.password}

but this gets me nowhere as this is again not a dictionary.

Conclusion

It seems to me that either the code or documentation shall be changed. My suspicion is that the code follows your design and you won't want to change it. So perhaps the documentation shall be a bit more clear about such usage.

This issue is somewhat related to #208 .

@fralik fralik added the kind/bug Something isn't working as expected label Jan 11, 2020
@sztomi
Copy link
Contributor

sztomi commented Jan 28, 2020

I just ran into this. The documentation clearly states this fact in multiple places and this is referenced also in PRs/issues connected to private repositories. A usable workaround is writing the config each time via poetry config http-basic.<reponame> <user> <password> where reponame is a repository previously configured.

@jacek-jablonski
Copy link

I can confirm this bug.

Temporary workaround would be setting
export POETRY_HTTP_BASIC_REPO=
and then POETRY_HTTP_BASIC_REPO_USERNAME and POETRY_HTTP_BASIC_REPO_PASSWORD are read.

@janjagusch
Copy link

janjagusch commented Jun 11, 2020

I cannot reproduce this issue anymore with the most recent version of poetry (v1.0.9).
Can anybody confirm that this has been fixed?

Seems like this was caused by the http-basic config still set without me realizing.

@jooh
Copy link

jooh commented Feb 2, 2022

I can confirm this bug.

Temporary workaround would be setting export POETRY_HTTP_BASIC_REPO= and then POETRY_HTTP_BASIC_REPO_USERNAME and POETRY_HTTP_BASIC_REPO_PASSWORD are read.

Can confirm this bug persists on poetry 1.1.12, and this workaround is effective

@neersighted
Copy link
Member

This is solved on the 1.2 branch.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

6 participants