Publish: Password requires username
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
What about adding it in the docstring of --password?
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.
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.
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?
Do you have an example for such an index?
@konsti -- Is there any objection to adding a real hint to the error trace? Can we just do that?
@konstin -- What about Zanie's concern above? I thought the conversation was veering towards only showing this when we hit a failure.
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.
Maybe @zanieb can provide an example then. If it's true then this could break users as-is.
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