From fe6a11d0db4e8547c0bbfeadd91f7563f5098f2b Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 14 Jul 2025 11:06:43 +0100 Subject: [PATCH] radicle: fix schemars macro on FetchPackSizeLimit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While running `cargo-semver-checks`, there was an issue that was surfaced regarding `serde(into)`, `serde(try_from)` and `schemars(transparent)` being used, and they are incompatible. This appeared to be a semver issue, on the side of `schemars`, since the issue would only appear when adding `radicle` as a fresh dependency. The intuition for this is that once `schemars` was updated locally, the same error appeared when attempting to build the `radicle` crate. To avoid this, `schemars` provides a `!` operator for the macro[^0]: > You can also “unset” serde attributes by including them with a ! prefix in a > schemars attribute, which will make schemars ignore the corresponding serde > attribute item [^0]: https://docs.rs/schemars_derive/latest/schemars_derive/derive.JsonSchema.html#attributes --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- crates/radicle/src/node/config.rs | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c640af10..c321a7b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -819,7 +819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1765,7 +1765,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2913,7 +2913,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.9.4", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2948,9 +2948,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.0.0-alpha.17" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ef2a6523400a2228db974a8ddc9e1d3deaa04f51bddd7832ef8d7e531bafcc" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" dependencies = [ "dyn-clone", "ref-cast", @@ -2961,9 +2961,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "1.0.0-alpha.17" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d4e1945a3c9e58edaa708449b026519f7f4197185e1b5dbc689615c1ad724d" +checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 23ec4c24..daf0c7e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ radicle-signals = { path = "crates/radicle-signals" } radicle-ssh = { path = "crates/radicle-ssh", default-features = false } radicle-systemd = { path = "crates/radicle-systemd" } radicle-term = { path = "crates/radicle-term" } -schemars = { version = "1.0.0-alpha.17" } +schemars = { version = "1.0.4" } serde = "1.0" serde_json = "1.0" shlex = "1.1.0" diff --git a/crates/radicle/src/node/config.rs b/crates/radicle/src/node/config.rs index fa1603b7..164591dd 100644 --- a/crates/radicle/src/node/config.rs +++ b/crates/radicle/src/node/config.rs @@ -148,7 +148,11 @@ impl Default for Limits { #[cfg_attr( feature = "schemars", derive(schemars::JsonSchema), - schemars(transparent) + schemars(transparent), + // serde's transparent and try_from/into will conflict, so we tell schemars + // to ignore them for its generation. + schemars(!try_from), + schemars(!into), )] pub struct FetchPackSizeLimit { #[cfg_attr(