Skip to content

feat: Transport logs error message for HTTP 413 responses#7261

Merged
philipphofmann merged 16 commits intomainfrom
feat/http-413-logging
Jan 27, 2026
Merged

feat: Transport logs error message for HTTP 413 responses#7261
philipphofmann merged 16 commits intomainfrom
feat/http-413-logging

Conversation

@philipphofmann
Copy link
Copy Markdown
Member

@philipphofmann philipphofmann commented Jan 23, 2026

📜 Description

Implements error logging for HTTP 413 (Content Too Large) responses to help users understand why their envelopes are being rejected. When the SDK receives an HTTP 413 response, it now logs an error message.

💡 Motivation and Context

Fixes #7248

Users need visibility into why their envelopes are being rejected by the server. HTTP 413 responses indicate the envelope is too large, but without detailed logging, it's difficult to diagnose which events or attachments are causing the issue.

This follows the Sentry SDK specification: https://develop.sentry.dev/sdk/expected-features/#dealing-with-network-failures

💚 How did you test it?

Unit tests and tested with a sample app and capturing a message exceeding 1 MiB to double-check if Relay returns 413.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Implements error logging for HTTP 413 (Content Too Large) responses to help users understand why their envelopes are being rejected. The error message includes the envelope size in bytes and item types.

Fixes #7248
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 23, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Transport logs error message for HTTP 413 responses by philipphofmann in #7261
  • Add install_groups support by noahsmartin in #7278

Bug Fixes 🐛

  • Prevent deadlock in SentryReachability by notifying observers outside the lock by itaybre in #7246

Internal Changes 🔧

  • (release) Fix changelog-preview permissions by BYK in #7262
  • Fix SwiftLint script warning by itaybre in #7267
  • Convert SentryNSDataSwizzling and SentryNSFileManagerSwizzling to Swift by itaybre in #7209
  • Convert SentrySessionReplayIntegration to Swift by itaybre in #7102
  • Fix incomplete comment by itaybre in #7239

Other

  • test: Fix SentryDestinationTests to handle array type for tags by itaybre in #7240

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 23, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 2fe8d45

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.039%. Comparing base (b0c71c8) to head (2fe8d45).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7261       +/-   ##
=============================================
- Coverage   85.050%   85.039%   -0.012%     
=============================================
  Files          470       472        +2     
  Lines        28396     28414       +18     
  Branches     12464     12468        +4     
=============================================
+ Hits         24151     24163       +12     
- Misses        4199      4202        +3     
- Partials        46        49        +3     
Files with missing lines Coverage Δ
Sources/Sentry/SentryHttpTransport.m 96.818% <100.000%> (+0.073%) ⬆️
...ources/Swift/Networking/SentryHttpStatusCode.swift 100.000% <100.000%> (ø)
...king/SentryHttpTransportHttpStatusCodeLogger.swift 100.000% <100.000%> (ø)

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0c71c8...2fe8d45. Read the comment docs.

@philipphofmann philipphofmann changed the title feat: Log error message for HTTP 413 responses feat: Transport logs error message for HTTP 413 responses Jan 26, 2026
@philipphofmann philipphofmann added the ready-to-merge Use this label to trigger all PR workflows label Jan 26, 2026
@philipphofmann philipphofmann marked this pull request as ready for review January 26, 2026 09:59
Copy link
Copy Markdown

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread Tests/SentryTests/Networking/SentryHttpTransportTests.swift
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 26, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1203.84 ms 1242.53 ms 38.70 ms
Size 24.14 KiB 1.09 MiB 1.06 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
edcda5a 1217.52 ms 1248.72 ms 31.20 ms
2e5230b 1207.41 ms 1240.41 ms 33.00 ms
3b01aaf 1194.98 ms 1210.36 ms 15.38 ms
387fbe4 1226.19 ms 1251.98 ms 25.79 ms
7e93d85 1205.28 ms 1243.71 ms 38.44 ms
5d67f5d 1225.33 ms 1262.76 ms 37.43 ms
45eb835 1210.40 ms 1233.39 ms 22.99 ms
37bc095 1210.00 ms 1242.69 ms 32.69 ms
ffe0649 1213.35 ms 1248.64 ms 35.29 ms
c424b6a 1220.38 ms 1248.18 ms 27.80 ms

App size

Revision Plain With Sentry Diff
edcda5a 24.14 KiB 1.08 MiB 1.06 MiB
2e5230b 24.14 KiB 1.04 MiB 1.02 MiB
3b01aaf 24.14 KiB 1.06 MiB 1.04 MiB
387fbe4 24.14 KiB 1.07 MiB 1.04 MiB
7e93d85 24.14 KiB 1.06 MiB 1.04 MiB
5d67f5d 24.14 KiB 1.06 MiB 1.04 MiB
45eb835 24.14 KiB 1.07 MiB 1.04 MiB
37bc095 24.14 KiB 1.06 MiB 1.04 MiB
ffe0649 24.14 KiB 1.06 MiB 1.04 MiB
c424b6a 24.14 KiB 1.06 MiB 1.04 MiB

Previous results on branch: feat/http-413-logging

Startup times

Revision Plain With Sentry Diff
9e8b08d 1218.43 ms 1253.39 ms 34.96 ms

App size

Revision Plain With Sentry Diff
9e8b08d 24.14 KiB 1.08 MiB 1.06 MiB

Copy link
Copy Markdown
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread Sources/Sentry/SentryHttpTransport.m
Comment thread Sources/Swift/Networking/SentryHttpTransportHttpStatusCodeLogger.swift Outdated
…andling

Introduces a new Swift enum to replace magic numbers with named constants for HTTP status codes. The enum is accessible from both Swift and Objective-C and includes custom equality operators for seamless Int comparison without requiring .rawValue. All status codes include MDN documentation references.

Updated SentryHttpTransportHttpStatusCodeLogger and its tests to use the enum, improving code readability and type safety.
…P transport

- Renamed SentryHttpStatusCodes to SentryHttpStatusCode (singular) for consistency
- Added HTTP 201 Created and 400 Bad Request status codes
- Updated SentryHttpTransport to use enum values for status code comparisons (200, 400, 429)
- Added comprehensive test suite for enum equality operators
- All equality operators support direct Int comparison without .rawValue

Updated files:
- SentryHttpStatusCode.swift (renamed from SentryHttpStatusCodes.swift)
- SentryHttpTransport.m: Uses enum for 200, 400, and 429 status codes
- SentryHttpTransportHttpStatusCodeLogger.swift: Updated enum references
- Tests: Updated all test files to use renamed enum
- Added SentryHttpStatusCodeTests.swift with 11 tests for equality and raw value verification
…ests

- Renamed raw value tests to status code value tests
- Changed all but one test to use == operator instead of .rawValue
- Kept one raw value test (testRawValue_shouldReturnCorrectInt) to verify rawValue works
- All 12 tests passing
Changed from (200 == SentryHttpStatusCode.ok) to (SentryHttpStatusCode.ok == 200) for more natural reading order.
@philipphofmann
Copy link
Copy Markdown
Member Author

philipphofmann commented Jan 27, 2026

@philprime, I added the HTTP status code enum. Please have another look 😃

Regenerated sdk_api.json to include the new SentryHttpStatusCode enum exposed to Objective-C via @objc annotation.
Removed @_spi(Private) and public modifiers from the equality operators. These operators are only needed within the module and don't need to be exposed as SPI.
Copy link
Copy Markdown
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread Tests/SentryTests/Networking/SentryHttpStatusCodeTests.swift
@philipphofmann philipphofmann enabled auto-merge (squash) January 27, 2026 09:12
@philipphofmann philipphofmann merged commit d191cf3 into main Jan 27, 2026
241 of 243 checks passed
@philipphofmann philipphofmann deleted the feat/http-413-logging branch January 27, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK Handling HTTP 413 [Apple]

2 participants