diff --git a/crates/uv-publish/src/lib.rs b/crates/uv-publish/src/lib.rs index 869bb9dec62e..eac5fedc9792 100644 --- a/crates/uv-publish/src/lib.rs +++ b/crates/uv-publish/src/lib.rs @@ -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}; @@ -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"); }; diff --git a/crates/uv/src/commands/publish.rs b/crates/uv/src/commands/publish.rs index d0259ed5d809..88dcdf684245 100644 --- a/crates/uv/src/commands/publish.rs +++ b/crates/uv/src/commands/publish.rs @@ -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. diff --git a/crates/uv/tests/it/publish.rs b/crates/uv/tests/it/publish.rs index b49b0a81b930..32f2419248e2 100644 --- a/crates/uv/tests/it/publish.rs +++ b/crates/uv/tests/it/publish.rs @@ -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 "### ); @@ -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 @@ -295,8 +296,11 @@ fn check_keyring_behaviours() { Request for dummy@https://test.pypi.org/legacy/?ok Request for dummy@test.pypi.org 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 dummy@test.pypi.org + 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 "### );