uv icon indicating copy to clipboard operation
uv copied to clipboard

Publish: Password requires username

Open konstin opened this issue 1 year ago • 6 comments

You can't use a password without a username in uv publish, which we can catch in clap directly.

New error when using only a password:

$ uv publish --password dummy
error: the following required arguments were not provided:
  --username <USERNAME>

Usage: uv.exe publish --username <USERNAME> --password <PASSWORD> [FILES]...

For more information, try '--help'.

Fixes #8023

konstin avatar Oct 09 '24 12:10 konstin

What about adding it in the docstring of --password?

konstin avatar Oct 09 '24 12:10 konstin

It would probably be best to include the hint in the error message, which would mean checking later manually instead of using Clap.

The short help won't show it if it's in the docstring.

zanieb avatar Oct 09 '24 13:10 zanieb

Yeah can we just add a hint when we see Failed to publish... with a password but no username? You can even use Miette if you want to make it a bit easier to render the hint. See crates/uv/src/commands/diagnostics.rs for an example.

charliermarsh avatar Oct 09 '24 17:10 charliermarsh

I think actually some indexes don't even require a username, just a password — this was an annoyance with twine in packse where I was forced to provide a dummy username — so we probably shouldn't enforce this until there's a failure?

zanieb avatar Oct 09 '24 18:10 zanieb

Do you have an example for such an index?

konstin avatar Oct 10 '24 07:10 konstin

@konsti -- Is there any objection to adding a real hint to the error trace? Can we just do that?

charliermarsh avatar Oct 10 '24 09:10 charliermarsh

@konstin -- What about Zanie's concern above? I thought the conversation was veering towards only showing this when we hit a failure.

charliermarsh avatar Oct 15 '24 11:10 charliermarsh

I thought the concern was that we should tell users about tokens?

We definitely can't support password-only without an example of an index and how that index would encode this in the HTTP message, the current serialization always requires a username.

konstin avatar Oct 15 '24 11:10 konstin

Maybe @zanieb can provide an example then. If it's true then this could break users as-is.

charliermarsh avatar Oct 15 '24 12:10 charliermarsh

There may be other use cases we need to support, but it is not a regression due to: https://github.com/astral-sh/uv/blob/01c44af3c3ffc9f5e78ef4b415305350c029d1e0/crates/uv-publish/src/lib.rs#L541

konstin avatar Oct 15 '24 12:10 konstin