diff --git a/CHANGELOG.md b/CHANGELOG.md index 6692b2c594..56e050c70d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +**Breaking Changes**: + +- Return status code `413` if a request is rejected due to size limits. ([#5474](https://github.com/getsentry/relay/pull/5474)) + ## 25.12.1 **Features**: diff --git a/relay-server/src/endpoints/common.rs b/relay-server/src/endpoints/common.rs index 83b595c758..2aa68a6811 100644 --- a/relay-server/src/endpoints/common.rs +++ b/relay-server/src/endpoints/common.rs @@ -133,6 +133,7 @@ impl IntoResponse for BadStoreRequest { // now executed asynchronously in `EnvelopeProcessor`. (StatusCode::FORBIDDEN, body).into_response() } + BadStoreRequest::Overflow(_) => (StatusCode::PAYLOAD_TOO_LARGE, body).into_response(), _ => { // In all other cases, we indicate a generic bad request to the client and render // the cause. This was likely the client's fault. diff --git a/tests/integration/test_basic.py b/tests/integration/test_basic.py index 0b3bd079a0..9adf52fab9 100644 --- a/tests/integration/test_basic.py +++ b/tests/integration/test_basic.py @@ -7,6 +7,7 @@ import pytest import signal import zlib +from requests import HTTPError def test_graceful_shutdown_with_in_memory_buffer(mini_sentry, relay): @@ -376,3 +377,16 @@ def test_root_project_same(mini_sentry, relay): same_dsn = mini_sentry.get_dsn_public_key(project_id) txn = send_transaction_with_dsc(mini_sentry, relay, project_id, same_dsn) assert txn["contexts"]["trace"]["client_sample_rate"] == 0.5 + + +def test_size_limit_status_code(mini_sentry, relay): + project_id = 42 + mini_sentry.add_basic_project_config(project_id) + relay = relay( + mini_sentry, + { + "limits": {"max_event_size": "1B"}, + }, + ) + with pytest.raises(HTTPError, match="413 Client Error"): + relay.send_event(project_id)