Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ private void setBreadcrumbs(final @NotNull SentryBaseEvent event) {
}
if (event.getBreadcrumbs() == null) {

@romtsn romtsn Aug 7, 2026

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.

m: wondering if we should now introduce a check for event.getBreadcrumbs().isEmpty() and still prefer the persisted breadcrumbs if the event's ones are empty? Or would it sacrifice correctness and we'd append the persisted breadcrumbs which are irrelevant?

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.

if we do that here, probably good to do the same in SentryClient.applyScope

event.setBreadcrumbs(breadcrumbs);
} else {
event.getBreadcrumbs().addAll(breadcrumbs);
}
// else: the event already carries its own breadcrumbs (e.g. a tombstone-merged native
// crash event), so appending the persisted ones here would duplicate entries.
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,21 @@ class ApplicationExitInfoEventProcessorTest {
assertEquals("Google Chrome", processed.contexts.browser!!.name)
}

@Test
fun `when backfillable event already has breadcrumbs, does not duplicate them with persisted ones`() {
// simulates a tombstone-merged native crash event, which already carries its own
// breadcrumb history captured at crash time, overlapping with what was persisted to disk
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())

val processed =
processEvent(hint, populateScopeCache = true) {
breadcrumbs = listOf(Breadcrumb.debug("own-crash-time-breadcrumb"))
}

assertEquals(1, processed.breadcrumbs!!.size)
assertEquals("own-crash-time-breadcrumb", processed.breadcrumbs!![0].message)
}

@Test
fun `when backfillable event is enrichable, does not backfill user ip`() {
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
Expand Down Expand Up @@ -670,10 +685,11 @@ class ApplicationExitInfoEventProcessorTest {

assertEquals("MainActivity", processed.transaction)
assertEquals(DEBUG, processed.level)
assertEquals(3, processed.breadcrumbs!!.size)
// breadcrumbs already set on the event are preserved as-is, not merged with the persisted
// ones, since the event already carries its own authoritative breadcrumb history
assertEquals(1, processed.breadcrumbs!!.size)
assertEquals("debug", processed.breadcrumbs!![0].type)
assertEquals("debug", processed.breadcrumbs!![1].type)
assertEquals("navigation", processed.breadcrumbs!![2].type)
assertEquals("test", processed.breadcrumbs!![0].message)

assertEquals("debug", processed.environment)
assertEquals("io.sentry.samples@1.1.0+220", processed.release)
Expand Down
Loading