diff --git a/CHANGELOG.md b/CHANGELOG.md index 5abd6d2d37..6f6108c0e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Emit outcomes for spans trimmed from a transaction. ([#5410](https://github.com/getsentry/relay/pull/5410)) - Support `sample` alias in CSP reports. ([#5554](https://github.com/getsentry/relay/pull/5554)) - Fix inconsistencies with Insights' expected attributes. ([#5561](https://github.com/getsentry/relay/pull/5561)) +- Validate that EAP integer attributes fit into `i64`. ([#5621](https://github.com/getsentry/relay/pull/5621)) **Features**: diff --git a/relay-event-normalization/src/eap/mod.rs b/relay-event-normalization/src/eap/mod.rs index 84e2ec7ef5..085c8728ae 100644 --- a/relay-event-normalization/src/eap/mod.rs +++ b/relay-event-normalization/src/eap/mod.rs @@ -123,7 +123,8 @@ pub fn normalize_attribute_types(attributes: &mut Annotated) { match (&mut inner.value.ty, &mut inner.value.value) { (Annotated(Some(Boolean), _), Annotated(Some(Value::Bool(_)), _)) => (), (Annotated(Some(Integer), _), Annotated(Some(Value::I64(_)), _)) => (), - (Annotated(Some(Integer), _), Annotated(Some(Value::U64(_)), _)) => (), + (Annotated(Some(Integer), _), Annotated(Some(Value::U64(u)), _)) + if i64::try_from(*u).is_ok() => {} (Annotated(Some(Double), _), Annotated(Some(Value::I64(_)), _)) => (), (Annotated(Some(Double), _), Annotated(Some(Value::U64(_)), _)) => (), (Annotated(Some(Double), _), Annotated(Some(Value::F64(_)), _)) => (), @@ -766,6 +767,10 @@ mod tests { "type": "integer", "value": "abc" }, + "invalid_int": { + "type": "integer", + "value": 9223372036854775808 + }, "missing_type": { "value": "value with missing type" }, @@ -807,6 +812,7 @@ mod tests { "type": "double", "value": -42 }, + "invalid_int": null, "invalid_int_from_invalid_string": null, "missing_type": null, "missing_value": null, @@ -867,6 +873,17 @@ mod tests { "some_other_field": "some_other_value" }, "_meta": { + "invalid_int": { + "": { + "err": [ + "invalid_data" + ], + "val": { + "type": "integer", + "value": 9223372036854775808 + } + } + }, "invalid_int_from_invalid_string": { "": { "err": [ diff --git a/tests/integration/test_spansv2.py b/tests/integration/test_spansv2.py index b58ef9aaaf..b43de57c87 100644 --- a/tests/integration/test_spansv2.py +++ b/tests/integration/test_spansv2.py @@ -73,6 +73,8 @@ def test_spansv2_basic( "attributes": { "foo": {"value": "bar", "type": "string"}, "array": {"value": ["foo", "bar"], "type": "array"}, + "valid_int": {"value": 9223372036854775807, "type": "integer"}, + "invalid_int": {"value": 9223372036854775808, "type": "integer"}, "invalid": {"value": True, "type": "string"}, "http.response_content_length": {"value": 17, "type": "integer"}, }, @@ -96,6 +98,8 @@ def test_spansv2_basic( "foo": {"type": "string", "value": "bar"}, "http.response_content_length": {"value": 17, "type": "integer"}, "http.response.body.size": {"value": 17, "type": "integer"}, + "valid_int": {"value": 9223372036854775807, "type": "integer"}, + "invalid_int": None, "invalid": None, "sentry.browser.name": {"type": "string", "value": "Python Requests"}, "sentry.browser.version": {"type": "string", "value": "2.32"}, @@ -118,12 +122,18 @@ def test_spansv2_basic( }, "_meta": { "attributes": { + "invalid_int": { + "": { + "err": ["invalid_data"], + "val": {"type": "integer", "value": 9223372036854775808}, + } + }, "invalid": { "": { "err": ["invalid_data"], "val": {"type": "string", "value": True}, } - } + }, } }, "name": "some op",