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

Improve error message when user fails to enter a username. #925

Open
Erotemic opened this issue Sep 9, 2022 · 0 comments
Open

Improve error message when user fails to enter a username. #925

Erotemic opened this issue Sep 9, 2022 · 0 comments

Comments

@Erotemic
Copy link

Erotemic commented Sep 9, 2022

This is simply a suggestion for a place where a better error message might improve UX.

It took me way too long to debug this issue, but in this recent CI run:

https://github.com/GERSL/pycold/runs/8263806866?check_suite_focus=true

I got an error:

Traceback (most recent call last):
  File "/home/runner/.local/bin/twine", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.local/lib/python3.8/site-packages/twine/__main__.py", line 33, in main
    error = cli.dispatch(sys.argv[1:])
  File "/home/runner/.local/lib/python3.8/site-packages/twine/cli.py", line 123, in dispatch
    return main(args.args)
  File "/home/runner/.local/lib/python3.8/site-packages/twine/commands/upload.py", line 198, in main
    return upload(upload_settings, parsed_args.dists)
  File "/home/runner/.local/lib/python3.8/site-packages/twine/commands/upload.py", line 127, in upload
    repository = upload_settings.create_repository()
  File "/home/runner/.local/lib/python3.8/site-packages/twine/settings.py", line 329, in create_repository
    self.username,
  File "/home/runner/.local/lib/python3.8/site-packages/twine/settings.py", line 131, in username
    return cast(Optional[str], self.auth.username)
  File "/home/runner/.local/lib/python3.8/site-packages/twine/auth.py", line 34, in username
    return utils.get_userpass_value(
  File "/home/runner/.local/lib/python3.8/site-packages/twine/utils.py", line 248, in get_userpass_value
    value = prompt_strategy()
  File "/home/runner/.local/lib/python3.8/site-packages/twine/auth.py", line 85, in username_from_keyring_or_prompt
    return self.prompt("username", input)
  File "/home/runner/.local/lib/python3.8/site-packages/twine/auth.py", line 96, in prompt
    return how(f"Enter your {what}: ")
EOFError: EOF when reading a line
Enter your username: failed to twine upload
Error: Process completed with exit code 1.

And I spent a lot of time focusing on the EOFError: EOF when reading a line part of the issue and I didn't really see the Enter your username:, especially because it was followed by failed to twine upload.

With the new change to enforcing token based credentials, I think it may be more common for users to forget to put --username __token__ when using a token as the password in a non-interactive session. So maybe raising a more clear ValueError indication: "A Username was not specified, please enter a valid username or rerun with --username token if using a token as a password or --username if using your username/password credentials"...

Maybe that's a bit too wordy, but something along those lines might be nice. (It might even be nicer to just have a --token <token> argument as an alias for --username __token__ --password <token>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant