Skip to content
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

http: do not overflow the 5MB limit when adding large messages to the builder #125

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

remeh
Copy link
Contributor

@remeh remeh commented Nov 6, 2024

The intake enforces a 5MB limit which is avoided during the serialization by creating enough different payload for each of them to be <5MB.

However, the previous logic was not properly taking into account the size of the currently serialised event. Most of time slipped under the radar because only small events are sent, and the limit is a bit lenient. But when sending big messages, it is possible to trigger this bug.

E.g. with ~800kB messages and maxMessageSize configured to 800*1024, with previous code, it was possible to create payloads bigger than 5MB:

payload size: 5620395
payload size: 5582400
payload size: 614
HTTP status code: 413
HTTP status code: 413
HTTP status code: 202

with the new logic, they're properly contained in <5MB payloads:

paylod size: 4801198
payload size: 4801198
payload size: 1601013
HTTP status code: 202
HTTP status code: 202
HTTP status code: 202

… builder.

The intake enforces a 5MB limit which is avoided during the serialization
by creating enough different payload for each of them to be <5MB.

However, the previous logic was not properly taking into account the size
of the currently serialised event. Most of time slipped under the radar
because only small events are sent, and the limit is a bit lenient.
But when sending big messages, it is possible to trigger this bug.

E.g. with ~800kB messages and `maxMessageSize` configured to `800*1024`,
with previous code, it was possible to create payloads bigger than 5MB:

```
payload size: 5620395
payload size: 5582400
payload size: 614
HTTP status code: 413
HTTP status code: 413
HTTP status code: 202
```

with the new logic, they're properly contained in <5MB payloads:

```
paylod size: 4801198
payload size: 4801198
payload size: 1601013
HTTP status code: 202
HTTP status code: 202
HTTP status code: 202
```
@remeh remeh requested a review from a team as a code owner November 6, 2024 14:45
Copy link
Contributor

@StephenWakely StephenWakely left a comment

Choose a reason for hiding this comment

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

Good catch! I think it needs to be byte length not char length though..

Copy link
Contributor

@StephenWakely StephenWakely left a comment

Choose a reason for hiding this comment

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

Nice

@remeh remeh merged commit bd63f2d into master Nov 8, 2024
4 checks passed
@remeh remeh deleted the remeh/max-size branch November 8, 2024 12:35
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.

2 participants