Skip to content

Commit e017d22

Browse files
romtsncodex
andcommitted
fix(android): Reject unknown exit timestamps
Do not use current SDK options when an exit timestamp is unavailable because an intervening app update cannot be ruled out. Co-Authored-By: Codex <noreply@openai.com>
1 parent 9e84ef4 commit e017d22

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

sentry-android-core/src/main/java/io/sentry/android/core/ApplicationExitInfoEventProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ private boolean isAppNotUpdated(final @NotNull Backfillable hint) {
550550
timestamp = null;
551551
}
552552
if (timestamp == null) {
553-
return true;
553+
return false;
554554
}
555555

556556
final PackageInfo packageInfo = ContextUtils.getPackageInfo(context, buildInfoProvider);

sentry-android-core/src/test/java/io/sentry/android/core/ApplicationExitInfoEventProcessorTest.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,9 @@ class ApplicationExitInfoEventProcessorTest {
391391
}
392392

393393
@Test
394-
fun `if environment is not persisted, uses environment from options`() {
395-
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
394+
fun `if environment is not persisted and app was not updated, uses environment from options`() {
395+
val hint = HintUtils.createWithTypeCheckHint(AbnormalExitHint(timestamp = 2_000))
396+
setLastUpdateTime(1_000)
396397

397398
val processed = processEvent(hint)
398399

@@ -423,6 +424,18 @@ class ApplicationExitInfoEventProcessorTest {
423424
assertNull(processed.release)
424425
}
425426

427+
@Test
428+
fun `if exit timestamp is unknown, leaves release empty`() {
429+
val hint = HintUtils.createWithTypeCheckHint(AbnormalExitHint())
430+
val processor = fixture.getSut(tmpDir)
431+
fixture.options.release = "io.sentry.samples@1.2.0+232"
432+
setLastUpdateTime(1_000)
433+
434+
val processed = processor.process(SentryEvent(), hint)!!
435+
436+
assertNull(processed.release)
437+
}
438+
426439
@Test
427440
fun `if last update time is invalid, leaves release empty`() {
428441
val hint = HintUtils.createWithTypeCheckHint(AbnormalExitHint(timestamp = 1_000))

0 commit comments

Comments
 (0)