diff --git a/rust_snuba/Cargo.lock b/rust_snuba/Cargo.lock index 052a07af86..07b5f1f6a7 100644 --- a/rust_snuba/Cargo.lock +++ b/rust_snuba/Cargo.lock @@ -388,6 +388,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "basic-cookies" version = "0.1.5" @@ -790,6 +796,41 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "darling" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.58", +] + +[[package]] +name = "darling_macro" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.58", +] + [[package]] name = "data-encoding" version = "2.5.0" @@ -825,6 +866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -1262,7 +1304,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1279,6 +1321,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.13.2" @@ -1398,7 +1446,7 @@ dependencies = [ "async-object-pool", "async-std", "async-trait", - "base64", + "base64 0.21.7", "basic-cookies", "crossbeam-utils", "form_urlencoded", @@ -1494,6 +1542,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -1504,6 +1558,17 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -1512,6 +1577,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", + "serde", ] [[package]] @@ -1681,7 +1747,7 @@ checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978" dependencies = [ "ahash", "anyhow", - "base64", + "base64 0.21.7", "bytecount", "clap", "fancy-regex", @@ -2233,7 +2299,7 @@ checksum = "f0a21c30f03223ae4a4c892f077b3189133689b8a659a84372f8422384ce94c9" dependencies = [ "deprecate-until", "fixedbitset", - "indexmap", + "indexmap 2.2.6", "integer-sqrt", "num-traits", "rustc-hash", @@ -2298,7 +2364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.2.6", ] [[package]] @@ -2748,7 +2814,7 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2834,6 +2900,7 @@ dependencies = [ "serde", "serde_json", "serde_path_to_error", + "serde_with", "statsdproxy", "thiserror", "tikv-jemallocator", @@ -2899,7 +2966,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64", + "base64 0.21.7", ] [[package]] @@ -3230,13 +3297,43 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.2.6", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -3647,7 +3744,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.2.6", "toml_datetime", "winnow", ] @@ -3848,7 +3945,7 @@ version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" dependencies = [ - "base64", + "base64 0.21.7", "log", "native-tls", "once_cell", diff --git a/rust_snuba/Cargo.toml b/rust_snuba/Cargo.toml index fabfb3e315..b393341f63 100644 --- a/rust_snuba/Cargo.toml +++ b/rust_snuba/Cargo.toml @@ -52,6 +52,7 @@ hyper = "1.2.0" tokio-stream = "0.1.15" data-encoding = "2.5.0" zstd = "0.12.3" +serde_with = "3.8.1" [patch.crates-io] diff --git a/rust_snuba/src/processors/errors.rs b/rust_snuba/src/processors/errors.rs index 83187b36d7..8956e1cf73 100644 --- a/rust_snuba/src/processors/errors.rs +++ b/rust_snuba/src/processors/errors.rs @@ -6,6 +6,8 @@ use schemars::{gen::SchemaGenerator, schema::Schema, JsonSchema}; use serde::de; use serde::{Deserialize, Serialize}; use serde_json::Value; +use serde_with::serde_as; +use serde_with::DefaultOnError; use std::collections::BTreeMap; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use uuid::Uuid; @@ -227,6 +229,7 @@ struct StackTrace { frames: Option>>, } +#[serde_as] #[derive(Debug, Deserialize, JsonSchema)] struct StackFrame { #[serde(default)] @@ -243,6 +246,7 @@ struct StackFrame { in_app: Option, #[serde(default)] colno: Option, + #[serde_as(deserialize_as = "DefaultOnError")] #[serde(default)] lineno: Option, } @@ -845,4 +849,39 @@ mod tests { // confused by our untagged enum/anyOf wrapper run_schema_type_test::("events", None); } + + #[test] + fn deserialize_invalid_lineno() { + const SERIALIZED: &str = r#" + { + "function": "foo", + "module": "app.hello", + "filename": "hello", + "abs_path": "hello", + "lineno": 90052021220, + "colno": 86472, + "in_app": true, + "context_line": null, + "data": null, + "errors": null, + "raw_function": null, + "image_addr": null, + "instruction_addr": null, + "addr_mode": null, + "package": null, + "platform": null, + "post_context": null, + "pre_context": null, + "source_link": null, + "symbol": null, + "symbol_addr": null, + "trust": null, + "vars": null, + "snapshot": null, + "lock": null + } + "#; + let deserialized: StackFrame = serde_json::from_str(SERIALIZED).unwrap(); + assert_eq!(deserialized.lineno, None); + } }