fix(android): mark tombstone and ANR exits as reported when the event is dropped - #6002
Open
markushi wants to merge 5 commits into
Open
fix(android): mark tombstone and ANR exits as reported when the event is dropped#6002markushi wants to merge 5 commits into
markushi wants to merge 5 commits into
Conversation
… is dropped Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
markushi
marked this pull request as ready for review
August 26, 2026 10:01
markushi
requested review from
0xadam-brown,
adinauer,
romtsn and
runningcode
as code owners
August 26, 2026 10:01
0xadam-brown
left a comment
Member
There was a problem hiding this comment.
Nice to fix this 👍
Lgtm save for the ambiguity of the EMPTY_ID, as called out by SentryBot here.
…ropped events Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…d on purpose Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment on lines
212
to
218
| options | ||
| .getClientReportRecorder() | ||
| .recordLostEvent(DiscardReason.SAMPLE_RATE, DataCategory.Error); | ||
| HintUtils.setEventDropReason(hint, EventDropReason.SAMPLE_RATE); | ||
| // setting event as null to not be sent as its been discarded by sample rate | ||
| event = null; | ||
| } |
There was a problem hiding this comment.
Bug: When an EventProcessor returns null, no EventDropReason is set. This causes ApplicationExitInfoHistoryDispatcher to repeatedly report the same dropped event on subsequent app starts.
Severity: HIGH
Suggested Fix
In SentryClient.processEvent, when an event is dropped because an EventProcessor returned null, set the EventDropReason.EVENT_PROCESSOR on the Hint. This will ensure that downstream consumers like ApplicationExitInfoHistoryDispatcher can correctly identify that the event was intentionally dropped and avoid re-processing it.
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/src/main/java/io/sentry/SentryClient.java#L212-L218
Potential issue: In `SentryClient.processEvent`, if an `EventProcessor` returns `null`
to drop an event, the code records a `DiscardReason.EVENT_PROCESSOR` but fails to set an
`EventDropReason` on the associated `Hint`. This causes a downstream issue in
`ApplicationExitInfoHistoryDispatcher`, which relies on a non-null `EventDropReason` to
mark a report as processed by calling `policy.markReported()`. Without the drop reason,
the report is never marked, leading to the same application exit event (e.g., ANR,
tombstone) being reported repeatedly on every subsequent application start.
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
The last reported marker (
last_tombstone_report/last_anr_report) was only written as a sideeffect of caching the envelope on disk. An event dropped by
beforeSendnever gets there, so thesame
ApplicationExitInfowas turned into an event again at every app start.ApplicationExitInfoHistoryDispatchernow writes the marker as well whencaptureEventreturnsSentryId.EMPTY_ID, through a newApplicationExitInfoPolicy.markReported(long). The successfulpath is unchanged.
💡 Motivation and Context
A discarded crash must stay discarded. This is how signal handler events already behave, because
OutboxSenderdeletes the outbox file independent of the result ofbeforeSend.Tombstoneevents discarded frombeforeSendare re-reported on every app launch #5973💚 How did you test it?
New test in
ApplicationExitIntegrationTestBase, so it runs for bothTombstoneIntegrationTestand
AnrV2IntegrationTest. It failed before the change and passes now. Full:sentry-android-core:testReleaseUnitTestis green.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
TombstonePolicydeletes the matching native outbox file before the capture, so native data cannotcome back if the merged event is lost. That is a separate defect.