Skip to content

feat(client-reports): Client report protocol#1144

Open
szokeasaurusrex wants to merge 12 commits into
szokeasaurusrex/envelope-filterfrom
szokeasaurusrex/client-report-protocol
Open

feat(client-reports): Client report protocol#1144
szokeasaurusrex wants to merge 12 commits into
szokeasaurusrex/envelope-filterfrom
szokeasaurusrex/client-report-protocol

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Jun 9, 2026

Copy link
Copy Markdown
Member

Added the client report protocol.

Resolves #1001
Resolves RUST-153

@github-actions

github-actions Bot commented Jun 9, 2026

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

Generated by 🚫 dangerJS against c5d137d

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 7872da8 to 131cae7 Compare June 9, 2026 13:40
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 66c55a9 to 2fc5269 Compare June 9, 2026 13:40
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 131cae7 to 91aa345 Compare June 9, 2026 14:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 2fc5269 to 6bd618a Compare June 9, 2026 14:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 91aa345 to 8ab55da Compare June 9, 2026 14:42
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 6bd618a to 1f9b20f Compare June 9, 2026 14:43
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 8ab55da to 15eeea4 Compare June 9, 2026 15:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 1f9b20f to a1c5872 Compare June 9, 2026 15:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 15eeea4 to ffbee4e Compare June 9, 2026 15:38
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from 41afa32 to ad0ada5 Compare June 9, 2026 15:49
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from ffbee4e to ac9351c Compare June 9, 2026 16:02
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from c738dd0 to ece93f5 Compare June 10, 2026 09:29
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch 2 times, most recently from 9e08f3a to f8521cc Compare June 10, 2026 09:31
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from ece93f5 to 181f46f Compare June 10, 2026 09:31
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from f8521cc to 193723f Compare June 10, 2026 13:52
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 181f46f to dbf16e8 Compare June 10, 2026 13:52
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

RUST-153

Comment thread sentry-types/src/protocol/client_report/mod.rs Outdated
Comment thread CHANGELOG.md Outdated

- Added [`TransportFactory::create_transport_with_options`](https://docs.rs/sentry-core/latest/sentry_core/trait.TransportFactory.html#method.create_transport_with_options), which constructs transports from [`TransportOptions`](https://docs.rs/sentry-core/latest/sentry_core/struct.TransportOptions.html) instead of full [`ClientOptions`](https://docs.rs/sentry-core/latest/sentry_core/struct.ClientOptions.html) ([#1142](https://github.com/getsentry/sentry-rust/pull/1142)).
- Added transport-specific options types and `with_options` constructors for built-in HTTP transports, including `ReqwestHttpTransportOptions`, `CurlHttpTransportOptions`, `UreqHttpTransportOptions`, and `EmbeddedSVCHttpTransportOptions` ([#1142](https://github.com/getsentry/sentry-rust/pull/1142)).
- Added client report protocol types in `sentry-types`, including [`ClientReport`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/struct.ClientReport.html), [`ClientReportItem`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/struct.ClientReportItem.html), [`DataCategory`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/enum.DataCategory.html), and [`DiscardReason`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/enum.DiscardReason.html), plus support for serializing [`client_report` envelope items](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/enum.EnvelopeItem.html#variant.ClientReport) ([#1144](https://github.com/getsentry/sentry-rust/pull/1144)).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These docs.rs links of course do not work yet, but should be accurate after release.

@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 10, 2026 14:31
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner June 10, 2026 14:31
Comment thread sentry-types/src/protocol/envelope.rs
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 193723f to 87946bc Compare June 12, 2026 10:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 543b2cc to 1121016 Compare June 12, 2026 10:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 87946bc to f0916b0 Compare June 12, 2026 12:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 1121016 to 7360117 Compare June 12, 2026 12:37
Comment thread sentry-types/src/macros.rs Outdated
Comment thread sentry-types/src/protocol/client_report/mod.rs Outdated

@lcian lcian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, please address bot comment as that looks legit, we would have anyways found that out when adding the category and de/serialization tests.

Comment thread sentry-types/src/protocol/client_report/mod.rs Outdated
Comment thread sentry-types/src/protocol/client_report/list.rs
Comment thread sentry-types/src/protocol/client_report/mod.rs
szokeasaurusrex added a commit that referenced this pull request Jun 18, 2026
This refactor should force us to make sure we add EnvelopeItemTypes corresponding to new EnvelopeItems: basically this sort of error should become impossible: #1144 (comment).
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-type-improvement branch from 263bcb0 to 5e3017a Compare June 18, 2026 15:05
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from 44a5c99 to cf7b15e Compare June 19, 2026 08:46
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-type-improvement branch from 5e3017a to 8034ba5 Compare June 19, 2026 08:46
Comment thread sentry-types/src/protocol/client_report/mod.rs
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from cf7b15e to fb0de20 Compare June 19, 2026 12:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-type-improvement branch from 8034ba5 to ea171be Compare June 19, 2026 12:08
@szokeasaurusrex szokeasaurusrex changed the base branch from szokeasaurusrex/envelope-type-improvement to szokeasaurusrex/envelope-filter June 19, 2026 16:05
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from fb0de20 to c49b952 Compare June 19, 2026 16:05
szokeasaurusrex and others added 12 commits June 19, 2026 18:33
This will allow us to add additional construction options, either to all transports or to individual transports, in the future without breaking the public API. This will be useful in #1004, as we will need to provide transports with a handle to record data losses.

For users who use a custom transport/transport factory, this change may produce a minor behavior breakage, as the `&ClientOptions` received by the `create_transport` method (or the closure, in the case of transport factories which are just closures) will no longer contain all of the options set when init-ing the SDK, only those options which are also present in `TransportOptions`. As the API remains fully compatible, however, we are not considering this to be a public API breakage, and will release these changes in a minor/patch release.

References [#1004](#1004)
References [RUST-156](https://linear.app/getsentry/issue/RUST-156/record-transport-drops-and-attach-client-report-envelopes)
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from c49b952 to c5d137d Compare June 19, 2026 16:33
Comment on lines +21 to +22
#[serde(default = "SystemTime::now", with = "utils::ts_seconds_float")]
timestamp: SystemTime,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The Report struct's timestamp field will fail to deserialize if the JSON value is explicitly null, because the custom deserializer does not handle null values.
Severity: HIGH

Suggested Fix

Modify the custom deserializer to handle null values. Implement visit_none in the SecondsTimestampVisitor to return a default value, or wrap the deserialization logic in a function that handles an Option<T> to correctly process null before it reaches the custom timestamp logic.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: sentry-types/src/protocol/client_report/mod.rs#L21-L22

Potential issue: The `Report` struct uses `#[serde(default = "SystemTime::now")]`
combined with a custom deserializer `#[serde(with = "utils::ts_seconds_float")]` for its
`timestamp` field. The `default` attribute is only triggered when the field is missing
from the JSON, not when it is explicitly `null`. If a client report is received with
`{"timestamp": null}`, `serde` will attempt to deserialize the `null` value using the
custom `ts_seconds_float` deserializer. This will fail because its internal visitor,
`SecondsTimestampVisitor`, does not implement `visit_none()` to handle `null` values,
causing the entire report to be dropped.

Also affects:

  • sentry-types/src/protocol/v7.rs:751
  • sentry-types/src/protocol/v7.rs:895
  • sentry-types/src/protocol/v7.rs:1143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants