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

Avoid enforcing URL check on initial publish #10182

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions crates/uv-publish/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{env, fmt, io};
use thiserror::Error;
use tokio::io::{AsyncReadExt, BufReader};
use tokio_util::io::ReaderStream;
use tracing::{debug, enabled, trace, Level};
use tracing::{debug, enabled, trace, warn, Level};
use url::Url;
use uv_client::{BaseClient, OwnedArchive, RegistryClientBuilder, UvRetryableStrategy};
use uv_configuration::{KeyringProviderType, TrustedPublishing};
Expand Down Expand Up @@ -469,10 +469,24 @@ pub async fn check_url(
.wrap_existing(client);

debug!("Checking for {filename} in the registry");
let response = registry_client
let response = match registry_client
.simple(filename.name(), Some(index_url), index_capabilities)
.await
.map_err(PublishError::CheckUrlIndex)?;
{
Ok(response) => response,
Err(err) => {
return match err.into_kind() {
uv_client::ErrorKind::PackageNotFound(_) => {
// The package doesn't exist, so we can't have uploaded it.
warn!(
"Package not found in the registry; skipping upload check for {filename}"
);
Ok(false)
}
kind => Err(PublishError::CheckUrlIndex(kind.into())),
};
}
};
let [(_, simple_metadata)] = response.as_slice() else {
unreachable!("We queried a single index, we must get a single response");
};
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/src/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub(crate) async fn publish(
}
} else if check_url.is_none() {
warn_user_once!(
"Using `--keyring-provider` with a password or token and no check url has no effect"
"Using `--keyring-provider` with a password or token and no check URL has no effect"
);
} else {
// We may be using the keyring for the simple index.
Expand Down
14 changes: 9 additions & 5 deletions crates/uv/tests/it/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ fn check_keyring_behaviours() {
----- stderr -----
warning: `uv publish` is experimental and may change without warning
Publishing 1 file to https://test.pypi.org/legacy/?ok
error: Failed to query check URL
Caused by: Package `ok` was not found in the registry
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/?ok
Caused by: Upload failed with status code 403 Forbidden. Server says: 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
"###
);

Expand All @@ -265,7 +266,7 @@ fn check_keyring_behaviours() {
----- stderr -----
warning: `uv publish` is experimental and may change without warning
Publishing 1 file to https://test.pypi.org/legacy/?ok
warning: Using `--keyring-provider` with a password or token and no check url has no effect
warning: Using `--keyring-provider` with a password or token and no check URL has no effect
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/?ok
Caused by: Upload failed with status code 403 Forbidden. Server says: 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
Expand Down Expand Up @@ -295,8 +296,11 @@ fn check_keyring_behaviours() {
Request for dummy@https://test.pypi.org/legacy/?ok
Request for [email protected]
warning: Keyring has no password for URL `https://test.pypi.org/legacy/?ok` and username `dummy`
error: Failed to query check URL
Caused by: Package `ok` was not found in the registry
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
Request for dummy@https://test.pypi.org/legacy/?ok
Request for [email protected]
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/?ok
Caused by: Upload failed with status code 403 Forbidden. Server says: 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
"###
);

Expand Down
Loading