-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
feat(actix): capture HTTP request body #731
Conversation
Add MaxRequestBodySize enum to control request body capture with options: - None: Don't capture request body (default) - Small: Capture up to 1000 bytes - Medium: Capture up to 10000 bytes - Always: Capture entire body Add max_request_body_size field to ClientOptions struct with default value of None
Add support for capturing request bodies in the Sentry middleware for Actix-Web. This includes: - Configurable request body size limits (Small/Medium/Always) - Support for JSON and form-urlencoded content types - Body capture and restoration logic to maintain request integrity - Additional span data enrichment Updates dependencies: - Add serde_json, actix-http, futures dependencies
Another question would be: Is the intention to capture up to the configured limit, or to discard any payloads that exceed the limit. |
The goal here is to discard payloads that exceed the limit. In some SDKs (e.g. Python) there is some more complex logic to handle payloads that exceed the max but in others (e.g. PHP) it's simply discarded. |
Implements a method to validate request body sizes against predefined limits: - None: Don't capture request bodies (default) - Small: Capture up to 1000 bytes - Medium: Capture up to 10000 bytes - Always: Capture entire body
- Add chunked transfer encoding check to prevent capturing chunked requests - Add strict content-type validation for JSON and form-urlencoded - Implement content length validation against size limits
Add new `Explicit(usize)` variant to `MaxRequestBodySize` enum, allowing users to specify custom maximum request body size limits for event capture.
It's already handle by the is_within_size_limit.
Setting the option to |
@pacifistes thanks for the contribution! 😄 |
Summary
This PR adds the ability to capture HTTP request bodies in the Sentry Actix middleware, allowing for better debugging and error tracking capabilities. The feature is configurable through the
max_request_body_size
option inClientOptions
.Changes
MaxRequestBodySize
enum to control request body capture behavior:None
: Don't capture request bodies (default)Small
: Capture up to 1000 bytesMedium
: Capture up to 10000 bytesAlways
: Capture entire bodyJSON
andform-urlencoded
content typesImplementation Details
application/json
andapplication/x-www-form-urlencoded
max_request_body_size
option