From 2e425d797bb58f015e23aef4c881508a31541b62 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Mon, 16 Feb 2026 14:20:18 +0100 Subject: [PATCH] Add handling for 413 upstream response --- src/Transport/ResultStatus.php | 11 +++++++++++ tests/Transport/HttpTransportTest.php | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Transport/ResultStatus.php b/src/Transport/ResultStatus.php index 130bc56a57..096ea2dd0c 100644 --- a/src/Transport/ResultStatus.php +++ b/src/Transport/ResultStatus.php @@ -57,6 +57,15 @@ public static function success(): self return self::getInstance('SUCCESS'); } + /** + * Returns an instance of this enum representing the fact that the event + * failed to be sent because the content was too large. + */ + public static function contentTooLarge(): self + { + return self::getInstance('CONTENT_TOO_LARGE'); + } + /** * Returns an instance of this enum representing the fact that the event * failed to be sent because of API rate limiting. @@ -94,6 +103,8 @@ public static function createFromHttpStatusCode(int $statusCode): self switch (true) { case $statusCode >= 200 && $statusCode < 300: return self::success(); + case $statusCode === 413: + return self::contentTooLarge(); case $statusCode === 429: return self::rateLimit(); case $statusCode >= 400 && $statusCode < 500: diff --git a/tests/Transport/HttpTransportTest.php b/tests/Transport/HttpTransportTest.php index 206261eb0c..7eb93cd3ff 100644 --- a/tests/Transport/HttpTransportTest.php +++ b/tests/Transport/HttpTransportTest.php @@ -114,6 +114,18 @@ public static function sendDataProvider(): iterable ], ]; + yield [ + new Response(413, [], ''), + ResultStatus::contentTooLarge(), + false, + [ + 'info' => [ + 'Sending event [%s] to %s [project:%s].', + 'Sent event [%s] to %s [project:%s]. Result: "content_too_large" (status: 413).', + ], + ], + ]; + ClockMock::withClockMock(1644105600); yield [