Skip to content

fix(scheduler): 'deck not found in limits map'#21014

Open
david-allison wants to merge 1 commit into
ankidroid:mainfrom
david-allison:limits-map-1
Open

fix(scheduler): 'deck not found in limits map'#21014
david-allison wants to merge 1 commit into
ankidroid:mainfrom
david-allison:limits-map-1

Conversation

@david-allison
Copy link
Copy Markdown
Member

Note

Assisted-by: Claude Opus 4.7 - initial debugging, wrote code which I designed

Fixes

Approach

A 'Check database' action is shown on the error message, which resolves the issue.

The error is no longer sent to ACRA

How Has This Been Tested?

Screenshot 2026-05-11 at 00 42 50
Index: AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt	(revision e3690dd6216a7cc790fffc54fed2dbefb6a9ae51)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt	(date 1778448859004)
@@ -71,6 +71,8 @@
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
 import androidx.work.WorkInfo
 import androidx.work.WorkManager
+import anki.backend.BackendError
+import anki.backend.backendError
 import anki.collection.OpChanges
 import anki.sync.SyncStatusResponse
 import com.google.android.material.progressindicator.LinearProgressIndicator
@@ -202,6 +204,7 @@
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import net.ankiweb.rsdroid.Translations
+import net.ankiweb.rsdroid.exceptions.BackendInvalidInputException
 import timber.log.Timber
 import java.io.File
 
@@ -429,6 +432,9 @@
     ) {
         Timber.i("DeckPicker:: Selected deck with id %d", deckId)
         launchCatchingTask {
+            throw BackendInvalidInputException(
+                backendError { message = "deck not found in limits map" }
+            )
             handleDeckSelection(deckId, selectionType)
             if (fragmented) {
                 // Calling notifyDataSetChanged() will update the color of the selected deck.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

A 'Check database' action is shown on the error message, which resolves
the issue.

The error is no longer sent to ACRA

Fixes 15195

Assisted-by: Claude Opus 4.7 - initial debugging, wrote code which I
designed
col.decks.select(deckADid)

val ex = assertFailsWith<Exception> { col.sched.counts() }
assertTrue(ex.isDeckNotFoundInLimitsMapException())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression cover: backend does not change the text


Timber.i("Error dialog displayed")

val helpAction = crashReportData?.helpAction?.takeIf { it.canExecute(this) }
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complexity comes from the fact that we cannot call showDatabaseErrorDialog without context being an AnkiActivity derivative

@david-allison
Copy link
Copy Markdown
Member Author

Unsure if this qualifies for 2.24.1 - reviewer's choice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"deck not found in limits map" should be more actionable

1 participant