Skip to content

Commit aeecb63

Browse files
committed
Don't filter away u64s smaller than i64max, and add integ test.
1 parent 740061a commit aeecb63

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

relay-event-normalization/src/eap/mod.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ pub fn normalize_attribute_types(attributes: &mut Annotated<Attributes>) {
123123
match (&mut inner.value.ty, &mut inner.value.value) {
124124
(Annotated(Some(Boolean), _), Annotated(Some(Value::Bool(_)), _)) => (),
125125
(Annotated(Some(Integer), _), Annotated(Some(Value::I64(_)), _)) => (),
126-
(Annotated(Some(Integer), _), Annotated(Some(Value::U64(_)), _)) => {
127-
attribute.meta_mut().add_error(ErrorKind::InvalidData);
128-
let original = attribute.value_mut().take();
129-
attribute.meta_mut().set_original_value(original);
126+
(Annotated(Some(Integer), _), Annotated(Some(Value::U64(u)), _)) => {
127+
if *u > i64::MAX as u64 {
128+
let original = attribute.value_mut().take();
129+
attribute.meta_mut().add_error(ErrorKind::InvalidData);
130+
attribute.meta_mut().set_original_value(original);
131+
}
130132
}
131133
(Annotated(Some(Double), _), Annotated(Some(Value::I64(_)), _)) => (),
132134
(Annotated(Some(Double), _), Annotated(Some(Value::U64(_)), _)) => (),
@@ -770,7 +772,7 @@ mod tests {
770772
"type": "integer",
771773
"value": "abc"
772774
},
773-
"invalid_int_i64": {
775+
"invalid_int": {
774776
"type": "integer",
775777
"value": 9223372036854775808
776778
},
@@ -815,8 +817,8 @@ mod tests {
815817
"type": "double",
816818
"value": -42
817819
},
820+
"invalid_int": null,
818821
"invalid_int_from_invalid_string": null,
819-
"invalid_int_i64": null,
820822
"missing_type": null,
821823
"missing_value": null,
822824
"supported_array_double": {
@@ -876,25 +878,25 @@ mod tests {
876878
"some_other_field": "some_other_value"
877879
},
878880
"_meta": {
879-
"invalid_int_from_invalid_string": {
881+
"invalid_int": {
880882
"": {
881883
"err": [
882884
"invalid_data"
883885
],
884886
"val": {
885887
"type": "integer",
886-
"value": "abc"
888+
"value": 9223372036854775808
887889
}
888890
}
889891
},
890-
"invalid_int_i64": {
892+
"invalid_int_from_invalid_string": {
891893
"": {
892894
"err": [
893895
"invalid_data"
894896
],
895897
"val": {
896898
"type": "integer",
897-
"value": 9223372036854775808
899+
"value": "abc"
898900
}
899901
}
900902
},

tests/integration/test_spansv2.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def test_spansv2_basic(
7373
"attributes": {
7474
"foo": {"value": "bar", "type": "string"},
7575
"array": {"value": ["foo", "bar"], "type": "array"},
76+
"valid_int": {"value": 9223372036854775807, "type": "integer"},
77+
"invalid_int": {"value": 9223372036854775808, "type": "integer"},
7678
"invalid": {"value": True, "type": "string"},
7779
"http.response_content_length": {"value": 17, "type": "integer"},
7880
},
@@ -96,6 +98,8 @@ def test_spansv2_basic(
9698
"foo": {"type": "string", "value": "bar"},
9799
"http.response_content_length": {"value": 17, "type": "integer"},
98100
"http.response.body.size": {"value": 17, "type": "integer"},
101+
"valid_int": {"value": 9223372036854775807, "type": "integer"},
102+
"invalid_int": None,
99103
"invalid": None,
100104
"sentry.browser.name": {"type": "string", "value": "Python Requests"},
101105
"sentry.browser.version": {"type": "string", "value": "2.32"},
@@ -118,12 +122,18 @@ def test_spansv2_basic(
118122
},
119123
"_meta": {
120124
"attributes": {
125+
"invalid_int": {
126+
"": {
127+
"err": ["invalid_data"],
128+
"val": {"type": "integer", "value": 9223372036854775808},
129+
}
130+
},
121131
"invalid": {
122132
"": {
123133
"err": ["invalid_data"],
124134
"val": {"type": "string", "value": True},
125135
}
126-
}
136+
},
127137
}
128138
},
129139
"name": "some op",

0 commit comments

Comments
 (0)