-
Notifications
You must be signed in to change notification settings - Fork 105
feat: Add dynamic max_bytes/max_chars definition #5500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This does for the `max_bytes` and `max_char` annotations what #5107 did for PII. In particular, this means that in future we can define the maximum sizes for attributes in `sentry-conventions`.
relay-event-derive/src/lib.rs
Outdated
| } else if ident == "pii" { | ||
| let s = meta.value()?.parse::<LitStr>()?; | ||
| rv.pii = parse_pii_value(s, &meta)?; | ||
| rv.pii = Some(meta.value()?.parse().unwrap()); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Dynamic max_bytes cannot reset size limits
before_process now decides whether to push a new SizeState via state.max_bytes().is_some(). With dynamic max_bytes, a present annotation can legitimately evaluate to None (meaning “no limit”), but this condition won’t push a state, so parent size limits keep applying and the subtree can’t reset/unlimit max_bytes.
relay-event-normalization/src/trimming.rs#L65-L75
relay/relay-event-normalization/src/trimming.rs
Lines 65 to 75 in 8f5b674
| ) -> ProcessingResult { | |
| // If we encounter a max_bytes or max_depth attribute it | |
| // resets the size and depth that is permitted below it. | |
| // XXX(iker): test setting only one of the two attributes. | |
| if state.max_bytes().is_some() || state.attrs().max_depth.is_some() { | |
| self.size_state.push(SizeState { | |
| size_remaining: state.max_bytes(), | |
| encountered_at_depth: state.depth(), | |
| max_depth: state.attrs().max_depth, | |
| }); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Dynamic max_bytes may not reset limits
before_process now decides to push a new SizeState using state.max_bytes().is_some(). For dynamic max_bytes, the function can return None to mean “no limit”, but this still needs to reset any inherited size limit. With the current check, inherited limits keep applying, causing unexpected trimming under fields that explicitly set dynamic max_bytes to None.
relay-event-normalization/src/trimming.rs#L65-L75
relay/relay-event-normalization/src/trimming.rs
Lines 65 to 75 in b0883e7
| ) -> ProcessingResult { | |
| // If we encounter a max_bytes or max_depth attribute it | |
| // resets the size and depth that is permitted below it. | |
| // XXX(iker): test setting only one of the two attributes. | |
| if state.max_bytes().is_some() || state.attrs().max_depth.is_some() { | |
| self.size_state.push(SizeState { | |
| size_remaining: state.max_bytes(), | |
| encountered_at_depth: state.depth(), | |
| max_depth: state.attrs().max_depth, | |
| }); | |
| } |
| Dynamic(ExprPath), | ||
| } | ||
|
|
||
| impl syn::parse::Parse for Pii { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just an improvement over the ad-hoc function, or did you need it for something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more a stylistic thing; I saw there's a trait in syn for exactly this use case and decided to implement it.
This does for the
max_bytesandmax_charannotations what #5107 did for PII. In particular, this means that in future we can define the maximum sizes for attributes insentry-conventions.Fixes #5499. Fixes RELAY-190.