Conversation
hkarmoush
force-pushed
the
fix-replay-network-detail-leak-local
branch
from
August 31, 2026 08:00
03b6649 to
0321cf3
Compare
There was a problem hiding this comment.
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0321cf3. Configure here.
buenaflor
reviewed
Sep 1, 2026
Comment on lines
+257
to
+262
| if (scopeObserver is HintAwareScopeObserver) { | ||
| await (scopeObserver as HintAwareScopeObserver) | ||
| .addBreadcrumbWithHint(addedBreadcrumb, resolvedHint); | ||
| } else { | ||
| await scopeObserver.addBreadcrumb(addedBreadcrumb); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if (scopeObserver is HintAwareScopeObserver) { | |
| await (scopeObserver as HintAwareScopeObserver) | |
| .addBreadcrumbWithHint(addedBreadcrumb, resolvedHint); | |
| } else { | |
| await scopeObserver.addBreadcrumb(addedBreadcrumb); | |
| } | |
| if (scopeObserver case final HintAwareScopeObserver observer) { | |
| await observer.addBreadcrumbWithHint(addedBreadcrumb, resolvedHint); | |
| } else { | |
| await scopeObserver.addBreadcrumb(addedBreadcrumb); | |
| } |
Contributor
There was a problem hiding this comment.
making it a bit more nicer with newer Dart features
Comment on lines
+5618
to
+5629
| // Hand-authored overload, mirroring addBreadcrumbFromJsonBytes above but | ||
| // for the two-byte-array descriptor shape (`([B[B)V`), since regenerating | ||
| // this file requires `scripts/generate-jni-bindings.sh`, which needs a | ||
| // full Android build toolchain not available in this environment. Re-run | ||
| // that script (or otherwise verify against a real jnigen run) before | ||
| // merging. | ||
| static final _id_addBreadcrumbFromJsonBytes$1 = _class.staticMethodId( | ||
| r'addBreadcrumbFromJsonBytes', | ||
| r'([B[B)V', | ||
| ); | ||
|
|
||
| static final _addBreadcrumbFromJsonBytes$1 = |
Contributor
There was a problem hiding this comment.
let's not hand-roll this. please re-generate this with e.g Flutter 3.44
hkarmoush
added a commit
to hkarmoush/sentry-dart
that referenced
this pull request
Sep 7, 2026
Use a pattern match instead of an `is` test followed by a redundant `as` cast when dispatching breadcrumbs to HintAwareScopeObserver. Review feedback from getsentry#3980.
hkarmoush
force-pushed
the
fix-replay-network-detail-leak-local
branch
from
September 7, 2026 11:10
0321cf3 to
8d16feb
Compare
Session Replay's opt-in HTTP body/header capture attached its data to the shared http breadcrumb, which then rode along into every subsequent Dart-captured error/transaction event and, on Android, into native crash events too - not just replay recordings (getsentry#3900). Request/response detail is now delivered via a Hint instead of breadcrumb.data, so it's never stored on the Scope. On Android it reaches the replay breadcrumb converter through a new side channel (ReplayNetworkDetailCache, correlated by an opaque replay_request_id) that never touches native Scope, closing the crash-event leak without touching the shipped Android replay rendering. iOS/FFI/Web never see the detail at all now, closing a zero-benefit leak there too (iOS doesn't render it in replay). Note: the Kotlin/Android native changes, including a hand-authored addition to the auto-generated JNI bindings in lib/src/native/java/binding.dart, could not be compiled or tested in this environment (no Android SDK/JDK/cmake available). They mirror existing generated/native patterns exactly but need verification via scripts/generate-jni-bindings.sh and a real device/emulator run before this is considered ready to ship.
…er API Populate ReplayNetworkDetailCache before the breadcrumb lands on the native Scope, closing the window where a replay segment built in between would never see the request/response detail. ScopeObserver.addBreadcrumb keeps its original one-argument signature so existing implementors aren't broken; a new opt-in HintAwareScopeObserver interface carries the Hint for observers (like NativeScopeObserver) that need it.
Per buenaflor's review on getsentry#3900: stop using a bespoke JNI side channel (ReplayNetworkDetailCache) to get captured HTTP request/response detail from Dart into a replay recording, since sentry-java's DefaultReplayBreadcrumbConverter already supports this via a SENTRY_REPLAY_NETWORK_DETAILS Hint (the same mechanism sentry-android's OkHttp integration uses). addBreadcrumb now carries the network detail directly instead of a separate captureReplayNetworkDetail call, so there's one atomic native call instead of two - removing the race Bugbot flagged on the earlier side-channel approach.
Use a pattern match instead of an `is` test followed by a redundant `as` cast when dispatching breadcrumbs to HintAwareScopeObserver. Review feedback from getsentry#3980.
hkarmoush
force-pushed
the
fix-replay-network-detail-leak-local
branch
from
September 17, 2026 22:11
8d16feb to
e8e3046
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

📜 Description
Reworks the Session Replay network-detail leak fix per @buenaflor's review on #3900.
httpbreadcrumb, passing it via aHintinstead (unchanged from the earlier attempt).ReplayNetworkDetailCache, keyed by a generatedreplay_request_id) to get that detail into a replay recording. Instead it's delivered through sentry-java's ownSENTRY_REPLAY_NETWORK_DETAILShint - the same mechanismSentryOkHttpInterceptoralready uses - soDefaultReplayBreadcrumbConverter's own (already-tested) conversion logic builds the replay event, rather than a hand-rolled reimplementation.addBreadcrumbnow carries the network detail directly instead of a separatecaptureReplayNetworkDetailcall, so there's one atomic native call instead of two - removing the race Bugbot flagged on the previous side-channel approach (fix(replay): Stop network detail capture leaking into non-replay events #3947).💡 Motivation and Context
Closes the leak in #3900: captured HTTP bodies/headers (opt-in via
enableReplayNetworkDetailsCapturing) were riding along on the sharedhttpbreadcrumb and ending up on unrelated events and native crash events, not just replay recordings.Supersedes #3947, which used a bespoke JNI cache that Bugbot flagged a race in and @buenaflor asked to be reworked to route through sentry-java's existing mechanism instead: #3900 (comment)
💚 How did you test it?
NativeScopeObserver/SentryNativeJava.addBreadcrumbseams (single-call contract, request/response detail merging).dart analyzeclean on bothsentryandsentry_flutter; full test suites pass.addBreadcrumbFromJsonBytesoverload) is hand-authored, mirroring the existing pattern for[Bdescriptors inbinding.dart, since regenerating it needs a full Android build toolchain not available in this environment - flagging for verification against a realjnigenrun before merge.📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
Would like a maintainer (or CI with a real Android toolchain) to verify the hand-authored JNI binding entry in
binding.dartagainst an actualjnigenrun before merging.