Repository navigation
Response context RFC #22
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c7c198b
Response context RFC
marandaneto d5b4118
fix name
marandaneto 125e50f
add link
marandaneto 5a1fb13
fixl ink
marandaneto de0edcf
add content
marandaneto 7eaec30
add drawback
marandaneto 96fd95a
add unresolved question
marandaneto f2a35e6
add option 3
marandaneto 8fd7026
fixes
marandaneto 4243161
fix pr id
marandaneto 2b0f5cb
fix
marandaneto f6c7cb8
fix
marandaneto 0df4b03
fix
marandaneto 78f1d88
fix
marandaneto 7436b0d
fix
marandaneto bd0728d
Update text/0022-response-context.md
marandaneto 8f2cdfd
code review
marandaneto 092cc5a
Merge branch 'main' into rfc/response-context
marandaneto f7b9796
remove is_redirect
marandaneto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| * Start Date: 2022-10-03 | ||
| * RFC Type: feature | ||
| * RFC PR: [#22](https://github.com/getsentry/rfcs/pull/22) | ||
| * RFC Status: approved | ||
| * RFC Driver: [Manoel Aranda Neto](https://github.com/marandaneto) | ||
|
|
||
| # Summary | ||
|
|
||
| Add `Response` interface that contains information on a HTTP response related to the event. | ||
|
|
||
| # Motivation | ||
|
|
||
| The [Request](https://develop.sentry.dev/sdk/event-payloads/request/) interface contains information on a HTTP request related to the event. However, there is no interface that contains information on a HTTP response related to the event. This RFC proposes a new interface called `Response`. | ||
|
|
||
| The `Request` interface has a few limitations: | ||
| * Does not accept arbitrary fields, so unknown fields are dropped during ingestion such as `status_code`. | ||
| * Response `headers` are not dropped during data scrubbing, See [issue](https://github.com/getsentry/relay/issues/1501). | ||
| * Adding `Response` data in the `Request` interface is semantically wrong anyways. | ||
|
|
||
| # Background | ||
|
|
||
| This is necessary to implement the `Failed HTTP Client requests automatically result in Events` feature that is described in this [DACI](https://www.notion.so/sentry/Failed-HTTP-Client-requests-automatically-result-in-Events-f6c21d2a58ce4f2c889a823fd1da0044). | ||
|
|
||
| Since the `Response` metadata is PII sensitive, it should be properly mapped, documented and scrubbed. | ||
|
|
||
| The [Dart Dio HTTP Client](https://docs.sentry.io/platforms/dart/configuration/integrations/dio/) integration already adds the `Response` field in the `Contexts` interface. | ||
|
|
||
| # Supporting Data | ||
|
|
||
| See [Supporting data](https://www.notion.so/sentry/Failed-HTTP-Client-requests-automatically-result-in-Events-f6c21d2a58ce4f2c889a823fd1da0044#0ca951d5216742dbaab02f5fd33b8fb5) section in the [DACI](https://www.notion.so/sentry/Failed-HTTP-Client-requests-automatically-result-in-Events-f6c21d2a58ce4f2c889a823fd1da0044). | ||
|
|
||
| # Proposal (Namely Option 2) | ||
|
|
||
| The proposal is adding a `Response` interface in the [Contexts interface](https://develop.sentry.dev/sdk/event-payloads/contexts/). | ||
|
|
||
| By doing this, we can keep the `Request` interface as it is and we don't need to change the data scrubbing rules for the `Request` field. | ||
|
|
||
| Adding it as part of the `Contexts`, we get a lot for free such as retained arbitrary fields and back compatibility. | ||
|
|
||
| ```json | ||
| { | ||
| "contexts": { | ||
| "response": { | ||
| "type": "response", | ||
| "cookies": "PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;", | ||
| "headers": { | ||
| "content-type": "text/html" | ||
| }, | ||
| "status_code": 500, | ||
| "body_size": 1000, | ||
| "arbitrary_field": "arbitrary" // arbitrary and retained fields for backwards compatibility when adding new fields | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| * `type`: `response` as `String`. | ||
| * `cookies`: Can be given unparsed as `String`, as `Dictionary`, or as a `List of Tuples`. | ||
| * `headers`: A `Dictionary` of submitted headers, this requires a special treatment in the data scrubbing rules. | ||
| * `status_code`: The HTTP status code, `Integer`. | ||
| * `body_size`: A `Number` (absolute/positive) indicating the size of the response body in bytes. | ||
|
|
||
| The `url`, `method`, `query_string`, `fragment`, `env` fields are not part of the `Response` interface and they should be set under the `Request` field, even if inferred from the HTTP response in case you don't have control over the HTTP Request object. | ||
|
|
||
| The `data` field won't be added to the `Response` interface, a phase 2 of this RFC will propose add Request and Response bodies are sent as attachments. | ||
|
|
||
| Fields that may contain PII: | ||
| * `cookies` | ||
| * `headers` | ||
|
|
||
| The PII rules should be similar to the [Request](https://develop.sentry.dev/sdk/event-payloads/request/) interface. | ||
|
|
||
| The difference is that `headers` contain response headers, such as this [issue](https://github.com/getsentry/relay/issues/1501). | ||
|
|
||
| ## Must have | ||
|
|
||
| The fields `Request#url` and `Response#status_code` should be indexed, people should be able to search for events with a specific `url` and/or `status_code`, also to alert on them. | ||
|
|
||
| # Drawbacks | ||
|
|
||
| The `Response` interface is PII sensitive, so we need to be careful about how we scrub it. | ||
|
marandaneto marked this conversation as resolved.
Resolved
|
||
|
|
||
| # Appendix | ||
|
|
||
| ## Removed Proposals | ||
|
marandaneto marked this conversation as resolved.
Resolved
|
||
|
|
||
| ### Option 1 | ||
|
|
||
| Adding a `Response` interface directly in the [Event payload](https://develop.sentry.dev/sdk/event-payloads/). | ||
|
|
||
| ```json | ||
| { | ||
| "response": { | ||
| // .. | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| This option is not chosen because it's not backwards compatible and we don't get a lot for free such as retained arbitrary fields and develop docs. | ||
|
|
||
| Also, the `Request` field may be soft deprecated in the future in favor of `Contexts#request`. | ||
|
|
||
| ### Option 3 | ||
|
|
||
| Expand the `Request` interface adding the missing fields. | ||
|
|
||
| Data scrubbing should consider response headers when scrubbing. | ||
|
|
||
| If we do that, the `Request` docs should be ammended that it contains the `Response` data as well otherwise it's semantically wrong. | ||
|
|
||
|
|
||
| This option is not chosen because PII rules would need to be changed, it's not backwards compatible and it's semantically wrong. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.