From 768c324a81a43be9a30bc08cb931fabe6f8f6139 Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Fri, 11 Aug 2023 10:49:18 -0400 Subject: [PATCH 01/10] chore: fix CI builds (#104) --- pbjson-build/src/escape.rs | 2 +- pbjson-build/src/generator/message.rs | 5 +++++ pbjson-test/build.rs | 2 +- pbjson-test/src/lib.rs | 6 +++++- pbjson-types/build.rs | 4 ++-- pbjson-types/descriptors.bin | Bin 107061 -> 114900 bytes pbjson-types/src/duration.rs | 2 +- pbjson-types/src/timestamp.rs | 17 ++++++++++++----- rust-toolchain.toml | 4 ++-- 9 files changed, 29 insertions(+), 13 deletions(-) diff --git a/pbjson-build/src/escape.rs b/pbjson-build/src/escape.rs index 554ac85..08a55e0 100644 --- a/pbjson-build/src/escape.rs +++ b/pbjson-build/src/escape.rs @@ -1,4 +1,4 @@ -///! Contains code to escape strings to avoid collisions with reserved Rust keywords +//! Contains code to escape strings to avoid collisions with reserved Rust keywords pub fn escape_ident(mut ident: String) -> String { // Copied from prost-build::ident diff --git a/pbjson-build/src/generator/message.rs b/pbjson-build/src/generator/message.rs index c7cb46e..2d0b277 100644 --- a/pbjson-build/src/generator/message.rs +++ b/pbjson-build/src/generator/message.rs @@ -374,6 +374,11 @@ fn write_serialize_scalar_variable( ) } _ => { + writeln!( + writer, + "{}#[allow(clippy::needless_borrow)]", + Indent(indent) + )?; writeln!( writer, "{}struct_ser.serialize_field(\"{}\", {}(&{}).as_str())?;", diff --git a/pbjson-test/build.rs b/pbjson-test/build.rs index 02bd410..b8907a7 100644 --- a/pbjson-test/build.rs +++ b/pbjson-test/build.rs @@ -28,7 +28,7 @@ fn main() -> Result<()> { .compile_well_known_types() .extern_path(".google.protobuf", "::pbjson_types") .extern_path(".test.external", "crate") - .bytes(&[".test"]) + .bytes([".test"]) .protoc_arg("--experimental_allow_proto3_optional"); if cfg!(feature = "btree") { diff --git a/pbjson-test/src/lib.rs b/pbjson-test/src/lib.rs index a2f604a..ad65a96 100644 --- a/pbjson-test/src/lib.rs +++ b/pbjson-test/src/lib.rs @@ -547,7 +547,11 @@ mod tests { decoded.optional_string = None; verify_decode(&decoded, "{}"); - let date = chrono::Utc.ymd(2072, 3, 1).and_hms_milli(5, 2, 5, 30); + let date = chrono::Utc + .with_ymd_and_hms(2072, 3, 1, 5, 2, 5) + .unwrap() + .checked_add_signed(chrono::Duration::milliseconds(30)) + .unwrap(); decoded.timestamp = Some(Timestamp { seconds: date.timestamp(), nanos: date.timestamp_subsec_nanos() as i32, diff --git a/pbjson-types/build.rs b/pbjson-types/build.rs index 99bebcc..9ef2b31 100644 --- a/pbjson-types/build.rs +++ b/pbjson-types/build.rs @@ -16,8 +16,8 @@ fn main() -> Result<()> { config .file_descriptor_set_path(&descriptor_path) .compile_well_known_types() - .disable_comments(&["."]) - .bytes(&[".google"]) + .disable_comments(["."]) + .bytes([".google"]) .skip_protoc_run(); let empty: &[&str] = &[]; diff --git a/pbjson-types/descriptors.bin b/pbjson-types/descriptors.bin index ad65b4f33b96c9d25d546635f705e2d4c67f922f..b7fe6319aab3428edd1325762abc3341b1272786 100644 GIT binary patch delta 25978 zcmd^odw3N^w(qX)-o1A^ubobK1qe+@2!uQ!Ac7DSAt(r83;`7%xJh8_*3z6A zb7ogtP9^?XUB}|AU-!uL96d7;PPGnNmSF_6fNea|JtuNSu=Ek8g{^ceNQDfgEG0{k zI*~cOtjl;4Jbc`Jx7QVe9%oueR$)}g!s&`ci^sb!?cEZ(wuGyUkycBru*IOxA%W3K zv-DFG76kHnp+)M>mxYCa!Mw1**6F9HITX65k-{+GXLnxStxWspboYrtZEQn##K~Z} zc3&$Lt8eOTYHRHqa@eqx8bx;J4IZb5*J_qg)w;CBT`{GX8!!0tSq;py8n~Ag_OK~# z=FqY}cD9u{=Zfmu$(JvvnmWC9`t0gC5$(d8x;Ed(db@LnHdsHIAS`M-x2P*k*D1|Q z8^n1XL;?(QN6gAgE9M1ILs6jEojYrEi6>1l1QQ~T2u$U*V2t#$lpC5+7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 impl Serialize for Duration { if self.nanos != 0 { s.push('.'); - let f = match split_nanos(self.nanos.abs() as u32) { + let f = match split_nanos(self.nanos.unsigned_abs()) { (millis, 0, 0) => format!("{:03}", millis), (millis, micros, 0) => format!("{:03}{:03}", millis, micros), (millis, micros, nanos) => format!("{:03}{:03}{:03}", millis, micros, nanos), diff --git a/pbjson-types/src/timestamp.rs b/pbjson-types/src/timestamp.rs index 7f2d22f..1722a9a 100644 --- a/pbjson-types/src/timestamp.rs +++ b/pbjson-types/src/timestamp.rs @@ -4,11 +4,17 @@ use serde::de::Visitor; use serde::Serialize; impl TryFrom for chrono::DateTime { - type Error = std::num::TryFromIntError; + type Error = &'static str; fn try_from(value: Timestamp) -> Result { let Timestamp { seconds, nanos } = value; - let dt = NaiveDateTime::from_timestamp(seconds, nanos.try_into()?); + let dt = NaiveDateTime::from_timestamp_opt( + seconds, + nanos + .try_into() + .map_err(|_| "out of range integral type conversion attempted")?, + ) + .ok_or("invalid or out-of-range datetime")?; Ok(Self::from_utc(dt, Utc)) } } @@ -69,9 +75,10 @@ mod tests { #[test] fn test_date() { - let datetime = FixedOffset::east(5 * 3600) - .ymd(2016, 11, 8) - .and_hms(21, 7, 9); + let datetime = FixedOffset::east_opt(5 * 3600) + .expect("time zone offset should be valid") + .with_ymd_and_hms(2016, 11, 8, 21, 7, 9) + .unwrap(); let encoded = datetime.to_rfc3339(); assert_eq!(&encoded, "2016-11-08T21:07:09+05:00"); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4e832fc..7b7e745 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.61" -components = [ "rustfmt", "clippy" ] +channel = "1.71" +components = ["rustfmt", "clippy"] From 08543808c94f491969ee279afef1d4a7f60c570e Mon Sep 17 00:00:00 2001 From: Jeffrey Smith II Date: Sun, 17 Sep 2023 11:52:15 -0400 Subject: [PATCH 02/10] chore: update prost to 0.12 (#111) * chore: update prost to 0.12 * chore: fix lint * chore: update descriptors --------- Co-authored-by: Raphael Taylor-Davies --- Cargo.toml | 10 ++++++---- pbjson-build/Cargo.toml | 4 ++-- pbjson-build/src/message.rs | 4 ++-- pbjson-test/Cargo.toml | 4 ++-- pbjson-types/Cargo.toml | 4 ++-- pbjson-types/descriptors.bin | Bin 114900 -> 121444 bytes pbjson-types/src/timestamp.rs | 6 +++--- rust-toolchain.toml | 2 +- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b13ec79..6797e52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,9 @@ [workspace] members = [ - "pbjson", - "pbjson-build", - "pbjson-test", - "pbjson-types", + "pbjson", + "pbjson-build", + "pbjson-test", + "pbjson-types", ] + +resolver = "2" \ No newline at end of file diff --git a/pbjson-build/Cargo.toml b/pbjson-build/Cargo.toml index 5774a66..153eb80 100644 --- a/pbjson-build/Cargo.toml +++ b/pbjson-build/Cargo.toml @@ -11,8 +11,8 @@ repository = "https://github.com/influxdata/pbjson" [dependencies] heck = "0.4" -prost = "0.11" -prost-types = "0.11" +prost = "0.12" +prost-types = "0.12" itertools = "0.10" [dev-dependencies] diff --git a/pbjson-build/src/message.rs b/pbjson-build/src/message.rs index 4364fca..8153153 100644 --- a/pbjson-build/src/message.rs +++ b/pbjson-build/src/message.rs @@ -183,7 +183,7 @@ fn field_modifier( field: &FieldDescriptorProto, field_type: &FieldType, ) -> FieldModifier { - let label = Label::from_i32(field.label.expect("expected label")).expect("valid label"); + let label = Label::try_from(field.label.expect("expected label")).expect("valid label"); if field.proto3_optional.unwrap_or(false) { assert_eq!(label, Label::Optional); return FieldModifier::Optional; @@ -217,7 +217,7 @@ fn field_type(descriptors: &DescriptorSet, field: &FieldDescriptorProto) -> Fiel Some(type_name) => resolve_type(descriptors, type_name.as_str()), None => { let scalar = - match Type::from_i32(field.r#type.expect("expected type")).expect("valid type") { + match Type::try_from(field.r#type.expect("expected type")).expect("valid type") { Type::Double => ScalarType::F64, Type::Float => ScalarType::F32, Type::Int64 | Type::Sfixed64 | Type::Sint64 => ScalarType::I64, diff --git a/pbjson-test/Cargo.toml b/pbjson-test/Cargo.toml index 5b7fb55..f1c6b5f 100644 --- a/pbjson-test/Cargo.toml +++ b/pbjson-test/Cargo.toml @@ -7,7 +7,7 @@ description = "Test resources for pbjson converion" repository = "https://github.com/influxdata/pbjson" [dependencies] -prost = "0.11" +prost = "0.12" pbjson = { path = "../pbjson" } pbjson-types = { path = "../pbjson-types" } serde = { version = "1.0", features = ["derive"] } @@ -24,5 +24,5 @@ chrono = "0.4" serde_json = "1.0" [build-dependencies] -prost-build = "0.11" +prost-build = "0.12" pbjson-build = { path = "../pbjson-build" } diff --git a/pbjson-types/Cargo.toml b/pbjson-types/Cargo.toml index 570639b..ba3c917 100644 --- a/pbjson-types/Cargo.toml +++ b/pbjson-types/Cargo.toml @@ -14,12 +14,12 @@ exclude = ["protos/*"] bytes = "1.0" chrono = { version = "0.4", default-features = false, features = ["alloc"] } pbjson = { path = "../pbjson", version = "0.5" } -prost = "0.11" +prost = "0.12" serde = { version = "1.0", features = ["derive"] } [dev-dependencies] serde_json = "1.0" [build-dependencies] # In alphabetical order -prost-build = "0.11" +prost-build = "0.12" pbjson-build = { path = "../pbjson-build", version = "0.5" } diff --git a/pbjson-types/descriptors.bin b/pbjson-types/descriptors.bin index b7fe6319aab3428edd1325762abc3341b1272786..0e370ea3c1b90e1764430aa0e542d4b6544182d6 100644 GIT binary patch delta 20473 zcmbV!3wTx4wQlBI&#axt&Q1a`yf)z>&xmNPD7lIdG%5)NtX92EL)bu0L&8Ub)Slih z6|4o1)pp?t71Rg?i%_&|F!g~5f<#4#yaWY7u%Z-;76jp9z5kexy*B;MJy);a=g0oX zn&Y2ijydL>W6rr&cHQfIw8k;LO{HGTfmc}ZZ@X{w4h-^~nAJVwDVF@ObFCeWaqeMH zE!pN|=Di&8Of!RL#LUMT?^OJ!Nb+EGm+8kxG{qYy$H&y%9UnSm=w*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CQ<$0kuKJ1|=O_;o0#Dfigcl1uRUd%RUEmeTGbSL+ zEb#C#oUVilX|4R;Vq*#$|RXOAjw=80=( z|Em0<>coAGO+R8~On5>ax9Hbo{6zFIGg9 z7Z4ou?BT_KjwGhyXX^BG_Qr>AWl>jnLAxFv8!u=z9Q4%oL2l7{IOrA06QU5ni-R6k z1Z^KA0Pghc5#6~Fzaq%yq-D{W%}EQRGvyTxHadc2*zj&r_;tv$FYO*c>jMJgD6Nn~ z*`%~a4tYhRjS4sqdE>^@Z8^7#;%=9Rf4ISlk23M&mh^(@>}U~vvgqDMA2ePU=b#0#wRLT`5w4!Z=BlGEMmdj?X-MQ1R7S{-me>f=#@M##6cC zv2lXR^)sD+F+va&$%_LafD@m2xHzC6pOXLb{6at#PZ@lz>+{MbqD*<@F@m$}J`MG)w0{+Is zjq{{#H4M7orPtoYE>mi>$S-(qZk8I|(OmHGTZHd+t3h(nOGnGuSgHu>nV@#jbHiC` zl-`RTKC95W#3)+YkB8K2U0^9NQ;1(iVnm+2QxPM;`go|Pe5(rqa`SiyZ}pDBe*alj ORkLO{HkGrL5B?tvUHmx! diff --git a/pbjson-types/src/timestamp.rs b/pbjson-types/src/timestamp.rs index 1722a9a..e7a1fc5 100644 --- a/pbjson-types/src/timestamp.rs +++ b/pbjson-types/src/timestamp.rs @@ -1,9 +1,9 @@ use crate::Timestamp; -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{DateTime, NaiveDateTime, TimeZone, Utc}; use serde::de::Visitor; use serde::Serialize; -impl TryFrom for chrono::DateTime { +impl TryFrom for DateTime { type Error = &'static str; fn try_from(value: Timestamp) -> Result { let Timestamp { seconds, nanos } = value; @@ -15,7 +15,7 @@ impl TryFrom for chrono::DateTime { .map_err(|_| "out of range integral type conversion attempted")?, ) .ok_or("invalid or out-of-range datetime")?; - Ok(Self::from_utc(dt, Utc)) + Ok(Utc.from_utc_datetime(&dt)) } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7b7e745..e724aeb 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.71" +channel = "1.72" components = ["rustfmt", "clippy"] From fc231ac0867a7903dc1d27b0830b4f00dd6825dc Mon Sep 17 00:00:00 2001 From: Nikolay Alexandrov Date: Sun, 17 Sep 2023 18:59:03 +0300 Subject: [PATCH 03/10] fix: parsing numbers more than i32 and u32 (#87) * fix: parsing numbers more than i32 and u32 * fix: f64::MANTISSA_DIGITS instead of 53 --------- Co-authored-by: Raphael Taylor-Davies --- pbjson-types/src/value.rs | 44 +++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/pbjson-types/src/value.rs b/pbjson-types/src/value.rs index 9ea05ad..c3fc87b 100644 --- a/pbjson-types/src/value.rs +++ b/pbjson-types/src/value.rs @@ -152,14 +152,20 @@ impl<'de> serde::de::Visitor<'de> for KindVisitor { where E: de::Error, { - self.visit_i32(v.try_into().map_err(de::Error::custom)?) + if v > -(1 << f64::MANTISSA_DIGITS) && v < 1 << f64::MANTISSA_DIGITS { + return Ok(Kind::NumberValue(v as f64)); + } + + Err(de::Error::custom( + "out of range integral type conversion attempted", + )) } fn visit_i128(self, v: i128) -> Result where E: de::Error, { - self.visit_i32(v.try_into().map_err(de::Error::custom)?) + self.visit_i64(v.try_into().map_err(de::Error::custom)?) } fn visit_u8(self, v: u8) -> Result @@ -187,14 +193,20 @@ impl<'de> serde::de::Visitor<'de> for KindVisitor { where E: de::Error, { - self.visit_u32(v.try_into().map_err(de::Error::custom)?) + if v < 1 << f64::MANTISSA_DIGITS { + return Ok(Kind::NumberValue(v as f64)); + } + + Err(de::Error::custom( + "out of range integral type conversion attempted", + )) } fn visit_u128(self, v: u128) -> Result where E: de::Error, { - self.visit_u32(v.try_into().map_err(de::Error::custom)?) + self.visit_u64(v.try_into().map_err(de::Error::custom)?) } fn visit_f32(self, v: f32) -> Result @@ -325,4 +337,28 @@ mod tests { assert!(serde_json::to_value(Value::from(f64::INFINITY)).is_err()); assert!(serde_json::to_value(Value::from(f64::NEG_INFINITY)).is_err()); } + + #[test] + fn parse_max_safe_integer() { + let max_safe_integer: i64 = 9007199254740991; + let json = serde_json::json!(max_safe_integer); + let vec = serde_json::to_vec(&json).unwrap(); + let pb = serde_json::from_slice::(&vec).unwrap(); + assert_eq!( + serde_json::to_value(pb).unwrap(), + serde_json::json!(max_safe_integer as f64) + ); + } + + #[test] + fn parse_min_safe_integer() { + let min_safe_integer: i64 = -9007199254740991; + let json = serde_json::json!(min_safe_integer); + let vec = serde_json::to_vec(&json).unwrap(); + let pb = serde_json::from_slice::(&vec).unwrap(); + assert_eq!( + serde_json::to_value(pb).unwrap(), + serde_json::json!(min_safe_integer as f64) + ); + } } From 688c8b48c70e2d9de10c5bb4204b29981c58c9e5 Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Sun, 17 Sep 2023 09:00:58 -0700 Subject: [PATCH 04/10] fix: Resolve Envoy xDS proto issues (#103) * fix: Escape Self since it is a reserved keyword * fix: Allow duplicate numbers in enums when aliases are enabled * fix: Avoid field name collisions with the map ident --- pbjson-build/src/descriptor.rs | 4 +- pbjson-build/src/escape.rs | 8 ++++ pbjson-build/src/generator/enumeration.rs | 5 +++ pbjson-build/src/generator/message.rs | 54 +++++++++++++---------- pbjson-build/src/message.rs | 4 +- pbjson-test/build.rs | 1 + pbjson-test/protos/duplicate_number.proto | 16 +++++++ pbjson-test/src/lib.rs | 5 +++ 8 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 pbjson-test/protos/duplicate_number.proto diff --git a/pbjson-build/src/descriptor.rs b/pbjson-build/src/descriptor.rs index 7bd5168..37f9ddc 100644 --- a/pbjson-build/src/descriptor.rs +++ b/pbjson-build/src/descriptor.rs @@ -12,7 +12,7 @@ use prost_types::{ FileDescriptorProto, FileDescriptorSet, MessageOptions, OneofDescriptorProto, }; -use crate::escape::escape_ident; +use crate::escape::{escape_ident, escape_type}; #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct Package { @@ -75,7 +75,7 @@ impl TypeName { pub fn to_upper_camel_case(&self) -> String { use heck::ToUpperCamelCase; - self.0.to_upper_camel_case() + escape_type(self.0.to_upper_camel_case()) } } diff --git a/pbjson-build/src/escape.rs b/pbjson-build/src/escape.rs index 08a55e0..4230a05 100644 --- a/pbjson-build/src/escape.rs +++ b/pbjson-build/src/escape.rs @@ -24,3 +24,11 @@ pub fn escape_ident(mut ident: String) -> String { }; ident } + +pub fn escape_type(mut ident: String) -> String { + // this keyword is not supported as a raw identifier and is therefore suffixed with an underscore. + if ident == "Self" { + ident += "_"; + } + ident +} diff --git a/pbjson-build/src/generator/enumeration.rs b/pbjson-build/src/generator/enumeration.rs index 05850af..0eadc39 100644 --- a/pbjson-build/src/generator/enumeration.rs +++ b/pbjson-build/src/generator/enumeration.rs @@ -11,6 +11,7 @@ use super::{ use crate::descriptor::{EnumDescriptor, TypePath}; use crate::generator::write_fields_array; use crate::resolver::Resolver; +use std::collections::HashSet; use std::io::{Result, Write}; pub fn generate_enum( @@ -22,9 +23,13 @@ pub fn generate_enum( ) -> Result<()> { let rust_type = resolver.rust_type(path); + let mut seen_numbers = HashSet::new(); let variants: Vec<_> = descriptor .values .iter() + // Skip duplicates if we've seen the number before + // Protobuf's `allow_alias` option permits duplicates if set + .filter(|variant| seen_numbers.insert(variant.number())) .map(|variant| { let variant_name = variant.name.clone().unwrap(); let variant_number = variant.number(); diff --git a/pbjson-build/src/generator/message.rs b/pbjson-build/src/generator/message.rs index 2d0b277..4834010 100644 --- a/pbjson-build/src/generator/message.rs +++ b/pbjson-build/src/generator/message.rs @@ -30,6 +30,7 @@ use super::{ Indent, }; use crate::descriptor::TypePath; +use crate::escape::escape_type; use crate::generator::write_fields_array; use crate::resolver::Resolver; @@ -522,7 +523,7 @@ fn write_deserialize_message( {indent} formatter.write_str("struct {name}") {indent} }} -{indent} fn visit_map(self, mut map: V) -> std::result::Result<{rust_type}, V::Error> +{indent} fn visit_map(self, mut map_: V) -> std::result::Result<{rust_type}, V::Error> {indent} where {indent} V: serde::de::MapAccess<'de>, {indent} {{"#, @@ -552,7 +553,7 @@ fn write_deserialize_message( if !message.fields.is_empty() || !message.one_ofs.is_empty() { writeln!( writer, - "{}while let Some(k) = map.next_key()? {{", + "{}while let Some(k) = map_.next_key()? {{", Indent(indent + 2) )?; @@ -587,7 +588,7 @@ fn write_deserialize_message( )?; writeln!( writer, - "{}let _ = map.next_value::()?;", + "{}let _ = map_.next_value::()?;", Indent(indent + 5), )?; writeln!(writer, "{}}}", Indent(indent + 4))?; @@ -598,12 +599,12 @@ fn write_deserialize_message( } else { writeln!( writer, - "{}while map.next_key::()?.is_some() {{", + "{}while map_.next_key::()?.is_some() {{", Indent(indent + 2) )?; writeln!( writer, - "{}let _ = map.next_value::()?;", + "{}let _ = map_.next_value::()?;", Indent(indent + 3) )?; writeln!(writer, "{}}}", Indent(indent + 2))?; @@ -725,7 +726,7 @@ fn write_deserialize_field_name( Indent(indent + 5), json_name, proto_name, - type_name + escape_type(type_name.to_string()) )?; } else { writeln!( @@ -733,7 +734,7 @@ fn write_deserialize_field_name( "{}\"{}\" => Ok(GeneratedField::{}),", Indent(indent + 5), json_name, - type_name + escape_type(type_name.to_string()) )?; } } @@ -789,7 +790,12 @@ fn write_fields_enum<'a, W: Write, I: Iterator>( )?; writeln!(writer, "{}enum GeneratedField {{", Indent(indent))?; for type_name in fields { - writeln!(writer, "{}{},", Indent(indent + 1), type_name)?; + writeln!( + writer, + "{}{},", + Indent(indent + 1), + escape_type(type_name.to_string()) + )?; } if ignore_unknown_fields { @@ -842,7 +848,7 @@ fn write_deserialize_field( Some(deserializer) => { write!( writer, - "map.next_value::<::std::option::Option<{}>>()?.map(|x| {}::{}(x.0))", + "map_.next_value::<::std::option::Option<{}>>()?.map(|x| {}::{}(x.0))", deserializer, resolver.rust_type(&one_of.path), field.rust_type_name() @@ -851,7 +857,7 @@ fn write_deserialize_field( None => { write!( writer, - "map.next_value::<::std::option::Option<_>>()?.map({}::{})", + "map_.next_value::<::std::option::Option<_>>()?.map({}::{})", resolver.rust_type(&one_of.path), field.rust_type_name() )?; @@ -860,7 +866,7 @@ fn write_deserialize_field( FieldType::Enum(path) => { write!( writer, - "map.next_value::<::std::option::Option<{}>>()?.map(|x| {}::{}(x as i32))", + "map_.next_value::<::std::option::Option<{}>>()?.map(|x| {}::{}(x as i32))", resolver.rust_type(path), resolver.rust_type(&one_of.path), field.rust_type_name() @@ -868,7 +874,7 @@ fn write_deserialize_field( } FieldType::Message(_) => writeln!( writer, - "map.next_value::<::std::option::Option<_>>()?.map({}::{})", + "map_.next_value::<::std::option::Option<_>>()?.map({}::{})", resolver.rust_type(&one_of.path), field.rust_type_name() )?, @@ -883,21 +889,21 @@ fn write_deserialize_field( FieldModifier::Optional => { write!( writer, - "map.next_value::<::std::option::Option<{}>>()?.map(|x| x as i32)", + "map_.next_value::<::std::option::Option<{}>>()?.map(|x| x as i32)", resolver.rust_type(path) )?; } FieldModifier::Repeated => { write!( writer, - "Some(map.next_value::>()?.into_iter().map(|x| x as i32).collect())", + "Some(map_.next_value::>()?.into_iter().map(|x| x as i32).collect())", resolver.rust_type(path) )?; } _ => { write!( writer, - "Some(map.next_value::<{}>()? as i32)", + "Some(map_.next_value::<{}>()? as i32)", resolver.rust_type(path) )?; } @@ -908,12 +914,12 @@ fn write_deserialize_field( match btree_map { true => write!( writer, - "{}map.next_value:: write!( writer, - "{}map.next_value::( FieldType::Message(_) => match field.field_modifier { FieldModifier::Repeated => { // No explicit presence for repeated fields - write!(writer, "Some(map.next_value()?)")?; + write!(writer, "Some(map_.next_value()?)")?; } - _ => write!(writer, "map.next_value()?")?, + _ => write!(writer, "map_.next_value()?")?, }, }, } @@ -1004,9 +1010,9 @@ fn write_encode_scalar_field( None => { return match field_modifier { FieldModifier::Optional => { - write!(writer, "map.next_value()?") + write!(writer, "map_.next_value()?") } - _ => write!(writer, "Some(map.next_value()?)"), + _ => write!(writer, "Some(map_.next_value()?)"), }; } }; @@ -1017,7 +1023,7 @@ fn write_encode_scalar_field( FieldModifier::Optional => { writeln!( writer, - "{}map.next_value::<::std::option::Option<{}>>()?.map(|x| x.0)", + "{}map_.next_value::<::std::option::Option<{}>>()?.map(|x| x.0)", Indent(indent + 1), deserializer )?; @@ -1025,7 +1031,7 @@ fn write_encode_scalar_field( FieldModifier::Repeated => { writeln!( writer, - "{}Some(map.next_value::>()?", + "{}Some(map_.next_value::>()?", Indent(indent + 1), deserializer )?; @@ -1038,7 +1044,7 @@ fn write_encode_scalar_field( _ => { writeln!( writer, - "{}Some(map.next_value::<{}>()?.0)", + "{}Some(map_.next_value::<{}>()?.0)", Indent(indent + 1), deserializer )?; diff --git a/pbjson-build/src/message.rs b/pbjson-build/src/message.rs index 8153153..6f0e47a 100644 --- a/pbjson-build/src/message.rs +++ b/pbjson-build/src/message.rs @@ -10,7 +10,7 @@ use prost_types::{ }; use crate::descriptor::{Descriptor, DescriptorSet, MessageDescriptor, Syntax, TypeName, TypePath}; -use crate::escape::escape_ident; +use crate::escape::{escape_ident, escape_type}; #[derive(Debug, Clone, Copy)] pub enum ScalarType { @@ -81,7 +81,7 @@ pub struct Field { impl Field { pub fn rust_type_name(&self) -> String { use heck::ToUpperCamelCase; - self.name.to_upper_camel_case() + escape_type(self.name.to_upper_camel_case()) } pub fn rust_field_name(&self) -> String { diff --git a/pbjson-test/build.rs b/pbjson-test/build.rs index b8907a7..040dd1c 100644 --- a/pbjson-test/build.rs +++ b/pbjson-test/build.rs @@ -13,6 +13,7 @@ fn main() -> Result<()> { root.join("syntax3.proto"), root.join("common.proto"), root.join("duplicate_name.proto"), + root.join("duplicate_number.proto"), root.join("escape.proto"), ]; diff --git a/pbjson-test/protos/duplicate_number.proto b/pbjson-test/protos/duplicate_number.proto new file mode 100644 index 0000000..97ef017 --- /dev/null +++ b/pbjson-test/protos/duplicate_number.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package test.duplicate_number; + +message Compressor { + enum CompressionLevel { + option allow_alias = true; + + DEFAULT = 0; + BEST_SPEED = 1; + COMPRESSION_LEVEL_1 = 1; + COMPRESSION_LEVEL_2 = 2; + COMPRESSION_LEVEL_3 = 3; + BEST_COMPRESSION = 3; + } +} diff --git a/pbjson-test/src/lib.rs b/pbjson-test/src/lib.rs index ad65a96..c4f1773 100644 --- a/pbjson-test/src/lib.rs +++ b/pbjson-test/src/lib.rs @@ -39,6 +39,11 @@ pub mod test { include!(concat!(env!("OUT_DIR"), "/test.duplicate_name.serde.rs")); } + pub mod duplicate_number { + include!(concat!(env!("OUT_DIR"), "/test.duplicate_number.rs")); + include!(concat!(env!("OUT_DIR"), "/test.duplicate_number.serde.rs")); + } + pub mod escape { include!(concat!( env!("OUT_DIR"), From 2889fe48f4565d445031c070070b597d6ca1e9b3 Mon Sep 17 00:00:00 2001 From: Thomas Gibson-Robinson Date: Sun, 17 Sep 2023 17:06:08 +0100 Subject: [PATCH 05/10] fix: follow cargo best practice in build.rs script (#90) Using env! inside the build.rs script makes it difficult to build this package with other build tools like bazel which sandbox execution, since the source directory might be at different paths between when the build.rs file is compiled, and when the resulting build script is executed. Cargo recommends that CARGO_MANIFEST_DIR is read at runtime instead: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts The above links also includes the promise that Cargo will set the cwd to the crate's directory. This patch uses this to find the descriptors.bin file. Co-authored-by: Raphael Taylor-Davies --- pbjson-types/build.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pbjson-types/build.rs b/pbjson-types/build.rs index 9ef2b31..4430fca 100644 --- a/pbjson-types/build.rs +++ b/pbjson-types/build.rs @@ -1,15 +1,13 @@ //! Compiles Protocol Buffers and FlatBuffers schema definitions into //! native Rust types. -use std::env; use std::path::PathBuf; type Error = Box; type Result = std::result::Result; fn main() -> Result<()> { - let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let descriptor_path = root.join("descriptors.bin"); + let descriptor_path: PathBuf = "descriptors.bin".into(); println!("cargo:rerun-if-changed={}", descriptor_path.display()); let mut config = prost_build::Config::new(); From 1adce943e9bfa353d1e207a8ae951c47cfeaea4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 17:16:36 +0100 Subject: [PATCH 06/10] chore(deps): update itertools requirement from 0.10 to 0.11 (#98) Updates the requirements on [itertools](https://github.com/rust-itertools/itertools) to permit the latest version. - [Changelog](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-itertools/itertools/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: itertools dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raphael Taylor-Davies --- pbjson-build/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbjson-build/Cargo.toml b/pbjson-build/Cargo.toml index 153eb80..ed71672 100644 --- a/pbjson-build/Cargo.toml +++ b/pbjson-build/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/influxdata/pbjson" heck = "0.4" prost = "0.12" prost-types = "0.12" -itertools = "0.10" +itertools = "0.11" [dev-dependencies] tempfile = "3.1" From 362f52c742d891a7dd7e849d60dcacea3c10051b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:42:32 +0100 Subject: [PATCH 07/10] chore(deps): update base64 requirement from 0.13 to 0.21 (#89) * chore(deps): update base64 requirement from 0.13 to 0.21 Updates the requirements on [base64](https://github.com/marshallpierce/rust-base64) to permit the latest version. - [Release notes](https://github.com/marshallpierce/rust-base64/releases) - [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md) - [Commits](https://github.com/marshallpierce/rust-base64/compare/v0.13.0...v0.21.0) --- updated-dependencies: - dependency-name: base64 dependency-type: direct:production ... Signed-off-by: dependabot[bot] * fix: fix removed methods * fix: indifferent padding --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raphael Taylor-Davies --- pbjson-types/src/wrappers.rs | 4 +++- pbjson/Cargo.toml | 2 +- pbjson/src/lib.rs | 26 +++++++++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pbjson-types/src/wrappers.rs b/pbjson-types/src/wrappers.rs index 25e6c21..0c5fae0 100644 --- a/pbjson-types/src/wrappers.rs +++ b/pbjson-types/src/wrappers.rs @@ -32,7 +32,9 @@ macro_rules! ser_bytes_value { where S: serde::Serializer, { - let value = pbjson::private::base64::encode(&self.value); + use pbjson::private::base64::engine::Engine; + let value = + pbjson::private::base64::engine::general_purpose::STANDARD.encode(&self.value); value.serialize(ser) } } diff --git a/pbjson/Cargo.toml b/pbjson/Cargo.toml index 40557e5..5d36f44 100644 --- a/pbjson/Cargo.toml +++ b/pbjson/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/influxdata/pbjson" [dependencies] serde = { version = "1.0", features = ["derive"] } -base64 = "0.13" +base64 = "0.21" [dev-dependencies] bytes = "1.0" diff --git a/pbjson/src/lib.rs b/pbjson/src/lib.rs index 0e17df0..ea7828b 100644 --- a/pbjson/src/lib.rs +++ b/pbjson/src/lib.rs @@ -22,6 +22,9 @@ pub mod private { /// Re-export base64 pub use base64; + use base64::engine::DecodePaddingMode; + use base64::engine::{GeneralPurpose, GeneralPurposeConfig}; + use base64::Engine; use serde::de::Visitor; use serde::Deserialize; use std::borrow::Cow; @@ -69,7 +72,15 @@ pub mod private { where E: serde::de::Error, { - let decoded = base64::decode_config(s, base64::STANDARD) + const INDIFFERENT_PAD: GeneralPurposeConfig = GeneralPurposeConfig::new() + .with_decode_padding_mode(DecodePaddingMode::Indifferent); + const STANDARD_INDIFFERENT_PAD: GeneralPurpose = + GeneralPurpose::new(&base64::alphabet::STANDARD, INDIFFERENT_PAD); + const URL_SAFE_INDIFFERENT_PAD: GeneralPurpose = + GeneralPurpose::new(&base64::alphabet::URL_SAFE, INDIFFERENT_PAD); + + let decoded = STANDARD_INDIFFERENT_PAD + .decode(s) .or_else(|e| match e { // Either standard or URL-safe base64 encoding are accepted // @@ -78,7 +89,7 @@ pub mod private { // Therefore if we error out on those characters, try again with // the URL-safe character set base64::DecodeError::InvalidByte(_, c) if c == b'-' || c == b'_' => { - base64::decode_config(s, base64::URL_SAFE) + URL_SAFE_INDIFFERENT_PAD.decode(s) } _ => Err(e), }) @@ -105,6 +116,7 @@ pub mod private { #[cfg(test)] mod tests { use super::*; + use base64::Engine; use bytes::Bytes; use rand::prelude::*; use serde::de::value::{BorrowedStrDeserializer, Error}; @@ -117,12 +129,12 @@ pub mod private { let raw: Vec<_> = std::iter::from_fn(|| Some(rng.gen())).take(len).collect(); for config in [ - base64::STANDARD, - base64::STANDARD_NO_PAD, - base64::URL_SAFE, - base64::URL_SAFE_NO_PAD, + base64::engine::general_purpose::STANDARD, + base64::engine::general_purpose::STANDARD_NO_PAD, + base64::engine::general_purpose::URL_SAFE, + base64::engine::general_purpose::URL_SAFE_NO_PAD, ] { - let encoded = base64::encode_config(&raw, config); + let encoded = config.encode(&raw); let deserializer = BorrowedStrDeserializer::<'_, Error>::new(&encoded); let a: Bytes = BytesDeserialize::deserialize(deserializer).unwrap().0; From 255585bb5f006cf7a5c39e75bfd66a3615cff6c2 Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:35:23 +0100 Subject: [PATCH 08/10] chore: prepare 0.6.0 (#112) --- pbjson-build/Cargo.toml | 2 +- pbjson-test/Cargo.toml | 2 +- pbjson-types/Cargo.toml | 6 +++--- pbjson/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pbjson-build/Cargo.toml b/pbjson-build/Cargo.toml index ed71672..95e41f8 100644 --- a/pbjson-build/Cargo.toml +++ b/pbjson-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbjson-build" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Generates Serialize and Deserialize implementations for prost message types" diff --git a/pbjson-test/Cargo.toml b/pbjson-test/Cargo.toml index f1c6b5f..7113ac5 100644 --- a/pbjson-test/Cargo.toml +++ b/pbjson-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbjson-test" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Test resources for pbjson converion" diff --git a/pbjson-types/Cargo.toml b/pbjson-types/Cargo.toml index ba3c917..23c1fdf 100644 --- a/pbjson-types/Cargo.toml +++ b/pbjson-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbjson-types" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] description = "Protobuf well known types with serde serialization support" edition = "2021" @@ -13,7 +13,7 @@ exclude = ["protos/*"] [dependencies] # In alphabetical order bytes = "1.0" chrono = { version = "0.4", default-features = false, features = ["alloc"] } -pbjson = { path = "../pbjson", version = "0.5" } +pbjson = { path = "../pbjson", version = "0.6" } prost = "0.12" serde = { version = "1.0", features = ["derive"] } @@ -22,4 +22,4 @@ serde_json = "1.0" [build-dependencies] # In alphabetical order prost-build = "0.12" -pbjson-build = { path = "../pbjson-build", version = "0.5" } +pbjson-build = { path = "../pbjson-build", version = "0.6" } diff --git a/pbjson/Cargo.toml b/pbjson/Cargo.toml index 5d36f44..95eb06d 100644 --- a/pbjson/Cargo.toml +++ b/pbjson/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbjson" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Utilities for pbjson conversion" From 9d19bfdaa903e5b7c786184bb3e396e9795778d1 Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com> Date: Mon, 18 Sep 2023 15:37:30 +0100 Subject: [PATCH 09/10] fix: prost deprecations (#113) --- pbjson-build/src/generator/enumeration.rs | 6 ++---- pbjson-build/src/generator/message.rs | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pbjson-build/src/generator/enumeration.rs b/pbjson-build/src/generator/enumeration.rs index 0eadc39..c833484 100644 --- a/pbjson-build/src/generator/enumeration.rs +++ b/pbjson-build/src/generator/enumeration.rs @@ -109,10 +109,9 @@ fn write_visitor( {indent} where {indent} E: serde::de::Error, {indent} {{ -{indent} use std::convert::TryFrom; {indent} i32::try_from(v) {indent} .ok() -{indent} .and_then({rust_type}::from_i32) +{indent} .and_then(|x| x.try_into().ok()) {indent} .ok_or_else(|| {{ {indent} serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self) {indent} }}) @@ -122,10 +121,9 @@ fn write_visitor( {indent} where {indent} E: serde::de::Error, {indent} {{ -{indent} use std::convert::TryFrom; {indent} i32::try_from(v) {indent} .ok() -{indent} .and_then({rust_type}::from_i32) +{indent} .and_then(|x| x.try_into().ok()) {indent} .ok_or_else(|| {{ {indent} serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self) {indent} }}) diff --git a/pbjson-build/src/generator/message.rs b/pbjson-build/src/generator/message.rs index 4834010..4203554 100644 --- a/pbjson-build/src/generator/message.rs +++ b/pbjson-build/src/generator/message.rs @@ -208,10 +208,10 @@ fn write_decode_variant( path: &TypePath, writer: &mut W, ) -> Result<()> { - writeln!(writer, "{}::from_i32({})", resolver.rust_type(path), value)?; + writeln!(writer, "{}::try_from({})", resolver.rust_type(path), value)?; write!( writer, - "{}.ok_or_else(|| serde::ser::Error::custom(format!(\"Invalid variant {{}}\", {})))", + "{}.map_err(|_| serde::ser::Error::custom(format!(\"Invalid variant {{}}\", {})))", Indent(indent), value ) From bc86f947b462d91f3d4d09252f6190ac79c64beb Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:00:56 +0100 Subject: [PATCH 10/10] chore: patch release pjson-build 0.6.2 (#114) --- pbjson-build/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbjson-build/Cargo.toml b/pbjson-build/Cargo.toml index 95e41f8..17e766e 100644 --- a/pbjson-build/Cargo.toml +++ b/pbjson-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbjson-build" -version = "0.6.0" +version = "0.6.2" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Generates Serialize and Deserialize implementations for prost message types"