A crash after Send troubleshooting report is uploaded with Never
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
The issue identifies CrashReportService.sendReport and ACRA's crash handling as the relevant flow; start by reading those implementations and the regression test in AnkiDroid/src/test/java/com/ichi2/anki/analytics/ManualCrashReportCrashTest.kt. Check how the Never preference affects reporting after a manual report is sent, then verify that a later crash is not uploaded without approval.
Written by the indexing model from the issue text.
Description
Assisted-by: Claude Fable 5.2 max
[EXISTING] A crash after Send troubleshooting report is uploaded with Never
Subject: [EXISTING] A crash after Send troubleshooting report is uploaded with Never
With reporting set to Never, sending a troubleshooting report from Help leaves ACRA enabled, so a later crash in that session is uploaded without asking.
⚠️ This issue existed before the PR and should likely be split off into a separate issue. The PR extends it to non-default profiles, whose approved reports the sender could not reach before.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/analytics/ManualCrashReportCrashTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/analytics/ManualCrashReportCrashTest.kt
new file mode 100644
index 0000000000..b3cda3b6a7
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/analytics/ManualCrashReportCrashTest.kt
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.analytics
+
+import android.app.Application
+import android.os.Bundle
+import androidx.core.content.edit
+import androidx.core.content.pm.PackageInfoCompat
+import androidx.test.core.app.ApplicationProvider
+import com.ichi2.anki.AnkiActivity
+import com.ichi2.anki.acraCoreConfigBuilder
+import com.ichi2.anki.common.analytics.Analytics
+import com.ichi2.anki.common.crashreporting.CrashReportService
+import com.ichi2.anki.common.crashreporting.CrashReporter.Companion.FEEDBACK_REPORT_KEY
+import com.ichi2.anki.common.crashreporting.CrashReporter.Companion.FEEDBACK_REPORT_NEVER
+import com.ichi2.anki.common.preferences.sharedPrefs
+import com.ichi2.anki.initializeAcraCrashReporter
+import com.ichi2.testutils.EmptyApplication
+import com.ichi2.testutils.common.OS
+import io.mockk.every
+import io.mockk.mockkConstructor
+import io.mockk.mockkObject
+import io.mockk.unmockkAll
+import io.mockk.verify
+import org.acra.ACRA
+import org.acra.ACRAConstants
+import org.acra.ReportField
+import org.acra.builder.ReportBuilder
+import org.acra.data.CrashReportData
+import org.acra.data.CrashReportDataFactory
+import org.acra.interaction.ToastInteraction
+import org.acra.scheduler.DefaultSenderScheduler
+import org.acra.sender.HttpSender
+import org.acra.sender.SendingConductor
+import org.junit.After
+import org.junit.Assume.assumeFalse
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.Robolectric
+import org.robolectric.RobolectricTestRunner
+import org.robolectric.annotation.Config
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
+
+@RunWith(RobolectricTestRunner::class)
+@Config(application = EmptyApplication::class)
+class ManualCrashReportCrashTest {
+ private val originalHandler = Thread.getDefaultUncaughtExceptionHandler()
+
+ @After
+ fun tearDown() {
+ unmockkAll()
+ Thread.setDefaultUncaughtExceptionHandler(originalHandler)
+ }
+
+ @Test
+ fun `Never ignores a crash after a manual report`() {
+ assumeFalse("ACRA's report file names contain ':', which Windows doesn't allow", OS.WINDOWS.isRunning())
+ val application = ApplicationProvider.getApplicationContext<Application>()
+ val crash = IllegalStateException("crash after a manual report")
+ // Leave collection, approval and sender delivery real; replace only slow collectors and transports.
+ mockkConstructor(CrashReportDataFactory::class)
+ every { anyConstructed<CrashReportDataFactory>().createCrashData(any()) } answers {
+ reportData(application, firstArg<ReportBuilder>().exception)
+ }
+ every { anyConstructed<CrashReportDataFactory>().collectStartUp() } returns Unit
+ mockkConstructor(ToastInteraction::class)
+ every { anyConstructed<ToastInteraction>().performInteraction(any(), any(), any()) } returns true
+ mockkConstructor(DefaultSenderScheduler::class)
+ every { anyConstructed<DefaultSenderScheduler>().scheduleReportSending(any()) } returns Unit
+ mockkConstructor(HttpSender::class)
+ every { anyConstructed<HttpSender>().send(any(), any(), any()) } returns Unit
+ mockkObject(Analytics)
+ every { Analytics.sendAnalyticsException(any(), any()) } returns Unit
+ with(application) { initializeAcraCrashReporter() }
+ application.sharedPrefs().edit(commit = true) { putString(FEEDBACK_REPORT_KEY, FEEDBACK_REPORT_NEVER) }
+
+ CrashReportService.sendReport(Robolectric.buildActivity(AnkiActivity::class.java).get())
+ // This enters the same ReportExecutor as uncaughtException without terminating the JVM.
+ ACRA.errorReporter.handleException(crash)
+ val senderConfig = CrashReportService.acraCoreConfigBuilder.withSendReportsInDevMode(true).build()
+ SendingConductor(application, senderConfig).sendReports(false, Bundle())
+
+ verify(exactly = 0) {
+ anyConstructed<HttpSender>().send(any(), match { it.getString(ReportField.STACK_TRACE) == crash.toString() }, any())
+ }
+ }
+
+ private fun reportData(
+ application: Application,
+ exception: Throwable?,
+ ) = CrashReportData().apply {
+ put(ReportField.STACK_TRACE, exception.toString())
+ put(ReportField.USER_CRASH_DATE, SimpleDateFormat(ACRAConstants.DATE_TIME_FORMAT_STRING, Locale.ENGLISH).format(Date()))
+ put(ReportField.FILE_PATH, application.filesDir.absolutePath)
+ put(
+ ReportField.APP_VERSION_CODE,
+ PackageInfoCompat.getLongVersionCode(application.packageManager.getPackageInfo(application.packageName, 0)),
+ )
+ }
+}
Found while reviewing https://github.com/ankidroid/Anki-Android/pull/23337
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 311
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ankidroid/Anki-Android#23806 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
ankidroid/Anki-Android#23798 ·
Maintainers usually reply within 1 day
-
Send troubleshooting report does nothing with Never but says it was sentPossibly taken @rishithareddychalla claimed this today. Opencode-scan
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23797 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Browse rows that fail to load show as empty linesPossibly taken @rishithareddychalla claimed this today. Opencode-scan
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23786 · 1 comment ·
Maintainers usually reply within 1 day
-
The note editor's Cards button shows card type names as HTMLPossibly taken @rishithareddychalla claimed this today. Opencode-scan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ankidroid/Anki-Android#23756 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Remove Collect againOpen
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
thisisartman/Meguri#211 ·
Maintainers usually reply within 1 day
-
follow-up
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Bug: Paused screen is never cleared, so spans and logs keep the previous fragment's screen nameOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-telemetry/opentelemetry-android#2309 ·
Maintainers usually reply within 1 day
-
📦 expo-location Android contributor: external needs review sdk-58 severity: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day