Skip to content

fix(limits): Enforce size limits consistently for all enevelope items#6250

Open
Dav1dde wants to merge 4 commits into
masterfrom
dav1d/size-limits
Open

fix(limits): Enforce size limits consistently for all enevelope items#6250
Dav1dde wants to merge 4 commits into
masterfrom
dav1d/size-limits

Conversation

@Dav1dde

@Dav1dde Dav1dde commented Jul 22, 2026

Copy link
Copy Markdown
Member

Closes: INGEST-1057

Enforces size, total size and count limits for all envelope items, instead of only selectively. By adding these limits we effectively make accepted envelopes much stricter, it also adds a new metric to verify the limits are appropriate.

Also adds a few more limits that were missing. All limits configured to 1 are forced by the protocol to be max 1. Items which share the same limit of 1 are mutually exclusive in an envelope.

There is a future improvement we can do in #6249 to improve how the limits are configured.

@linear-code

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

INGEST-1057

@Dav1dde
Dav1dde force-pushed the dav1d/size-limits branch from a0056d0 to 1401bbc Compare July 22, 2026 07:29
@Dav1dde
Dav1dde marked this pull request as ready for review July 22, 2026 07:31
@Dav1dde
Dav1dde requested a review from a team as a code owner July 22, 2026 07:31
@Dav1dde Dav1dde mentioned this pull request Jul 22, 2026
cursor[bot]

This comment was marked as outdated.

@Dav1dde
Dav1dde force-pushed the dav1d/size-limits branch from 1401bbc to 046d868 Compare July 22, 2026 07:33
@Dav1dde
Dav1dde marked this pull request as draft July 22, 2026 07:33
Comment thread relay-server/src/utils/sizes.rs
@Dav1dde
Dav1dde force-pushed the dav1d/size-limits branch from 046d868 to 0513a8e Compare July 22, 2026 07:55
@Dav1dde
Dav1dde marked this pull request as ready for review July 22, 2026 08:11
Comment thread relay-server/src/utils/sizes.rs
cursor[bot]

This comment was marked as resolved.

@Dav1dde Dav1dde self-assigned this Jul 22, 2026
Comment thread relay-config/src/config.rs Outdated
Comment thread relay-server/src/utils/sizes.rs Outdated
Comment thread relay-config/src/config.rs
Comment thread relay-config/src/config.rs Outdated
item_size: config.max_profile_size(),
total_count: 1,
total_size: config.max_profile_size(),
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a valid concern right?

Comment thread relay-server/src/utils/sizes.rs
Comment on lines +136 to +139
None => {
// Shouldn't be possible, if it still happens due to a bug, be defensive.
debug_assert!(false);
&mut empty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to create a sentry error here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered it but it's a lot of noise for something that is already enforced at compile time through the match. I think I'd rather look into getting rid of the None case so we can fully rely on the compiler.

"reason": "profiling_too_many_profiles",
"timestamp": time_within_delta(),
"quantity": 2,
"reason": "too_large:profile",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to consider: add a separate too_many reason to differentiate between count vs size exceeds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I also ideally want to improve the error message returned to the SDK. Will keep that as a follow-up.

Comment thread relay-server/src/utils/sizes.rs Outdated
Comment thread relay-server/src/utils/sizes.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants