Skip to content

Conversation

@loewenheim
Copy link
Contributor

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.

Fixes #5499. Fixes RELAY-190.

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`.
@loewenheim loewenheim requested a review from a team as a code owner December 17, 2025 15:47
@linear
Copy link

linear bot commented Dec 17, 2025

} 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.

Copy link

@cursor cursor bot left a 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

) -> 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,
});
}

Fix in Cursor Fix in Web


Copy link

@cursor cursor bot left a 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

) -> 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,
});
}

Fix in Cursor Fix in Web


Dynamic(ExprPath),
}

impl syn::parse::Parse for Pii {
Copy link
Member

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement dynamic computation of maximum data sizes

4 participants