From 7ae5ab55d59978ca5c8e9d119ccbd12952f04d8e Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Fri, 3 Nov 2023 04:30:29 -0400 Subject: [PATCH] properly handle the server's publish response --- src/publish.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/publish.rs b/src/publish.rs index 4a7cde9..334400a 100644 --- a/src/publish.rs +++ b/src/publish.rs @@ -498,6 +498,13 @@ async fn get_index_metas( Ok(crate_versions) } +#[derive(Debug, Clone, Deserialize, Eq, PartialEq)] +pub struct PublishWarnings { + pub invalid_categories: Vec, + pub invalid_badges: Vec, + pub other: Vec, +} + async fn process_crates( config: &Config, crate_versions: HashMap>, @@ -570,17 +577,35 @@ async fn process_crates( debug!(status = ?resp.status(), "rcvd server response to publish request"); - let resp_body: serde_json::Value = resp + let warnings: PublishWarnings = resp .error_for_status()? .json() .await?; - debug!("server response body:\n{resp_body:#?}"); + let mut any_warnings = false; + + for warning in warnings.invalid_categories.iter() { + warn!(%crate_name, %version, "registry server invalid category warning: {}", warning); + any_warnings = true; + } + + for warning in warnings.invalid_badges.iter() { + warn!(%crate_name, %version, "registry server invalid badge warning: {}", warning); + any_warnings = true; + } + + for warning in warnings.other.iter() { + warn!(%crate_name, %version, "registry server 'other' warning: {}", warning); + any_warnings = true; + } + + trace!("server response body:\n{warnings:#?}"); info!( %crate_name, %version, - "published crate version", + any_warnings, + "published crate version!", ); } }