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

Setting credentials fails when password starts with a hyphen #4699

Closed
3 tasks done
twoolie opened this issue Nov 2, 2021 · 8 comments · Fixed by #8850
Closed
3 tasks done

Setting credentials fails when password starts with a hyphen #4699

twoolie opened this issue Nov 2, 2021 · 8 comments · Fixed by #8850
Labels
area/docs/faq Frequently duplicated/potential addition to FAQ area/docs Documentation issues/improvements

Comments

@twoolie
Copy link

twoolie commented Nov 2, 2021

  • 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: NixOS 21.05

  • Poetry version: 1.1.11

Issue

When setting repository credentials with poetry config http-basic.custom-repo gitlab-ci-token ${GITLAB_JOB_TOKEN} the command will fail any time the GITLAB_JOB_TOKEN begins with a hyphen. The command line parser tries to treat the password as an option.

The current workaround is to use double hyphen e.g. poetry config http-basic.custom-repo -- gitlab-ci-token ${GITLAB_JOB_TOKEN}

This should either be fixed in the option parser, or the workaround documented in the manual.

@twoolie twoolie added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 2, 2021
@paketb0te
Copy link

paketb0te commented Oct 11, 2022

We ran into the same issue due to the ${GITLAB_JOB_TOKEN} (which is generated by GitLab dynamically) sometimes starting with a dash - and thus, poetry interpreting the next character as an option, which it then obviously can't find.

@twoolie how did you find the workaround using -- ? It works in our case as well, just curious to understand the mechanics behind it.

@dimbleby
Copy link
Contributor

this is just regular behaviour for command line programs. eg try to grep for a string that begins with a hyphen: it'll try to interpret it as an option.

See also #4853.

Nothing to do here.

@neersighted neersighted added area/docs Documentation issues/improvements area/docs/faq Frequently duplicated/potential addition to FAQ and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 1, 2022
@neersighted
Copy link
Member

Agreed, this is standard behavior of CLI applications, and there is no need for a workaround as the proper solution (-- to terminate options parsing in the Unix tradition) is available. I'm leaving this open as this seems like an excellent FAQ candidate.

@clintonroy
Copy link
Contributor

we could modify the input maybe, poetry config key==--value would get around it.

@neersighted
Copy link
Member

I'm personally not enthused about adding some custom tokenization/splitting when what we have works fine and is stable, especially as certain usernames with whatever token we choose would become impossible to express.

@twoolie
Copy link
Author

twoolie commented Nov 1, 2022

@paketb0te the workaround works well. I feel that it's a good enough solution. I think that it should be documented and that the examples in the docs should always use -- so that people don't get caught out when try to do this in their CI scripts. Admittedly this is less critical for me personally since gitlab started prefixing their tokens.

@paketb0te
Copy link

@twoolie yeah it works great, I just was not aware that this exists (using double hyphen to stop parsing options) 😄

I agree there is nothing to fix here, except maybe adding a hint in the docs / FAQ.

Copy link

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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/docs/faq Frequently duplicated/potential addition to FAQ area/docs Documentation issues/improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants