Skip to content

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

Merged
BrayanDSO merged 1 commit into
ankidroid:mainfrom
david-allison:limits-map-1
Jun 15, 2026
Merged

fix(scheduler): 'deck not found in limits map'#21014
BrayanDSO merged 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

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

@mikehardy mikehardy left a comment

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.

I like it but this feels more like a feature than a bugfix, and it's already in an area where I user might be in trouble so to speak. It's not great to continue leaving them without the ability to fix, now that we know it's possible, but there's always a risk of something unintended - I'd rather this marinate on main for a while

if (shouldDismiss) {
dismiss()
}
if (helpAction!!.execute(this@showError)) dismiss()

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.

reasoning through the !! to verify safety - there wouldn't be a neutralButton at all if the helpAction didn't exist above, ergo for the listener on neutral to be called, the helpAction is non null

@mikehardy mikehardy added Needs Second Approval Has one approval, one more approval to merge and removed Queued for Cherry Pick to Stable Branch labels Jun 8, 2026
@david-allison

david-allison commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Works for me, it's been a longstanding issue and I was hoping for a fast 2.25

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
@BrayanDSO
BrayanDSO added this pull request to the merge queue Jun 15, 2026
Merged via the queue into ankidroid:main with commit 611f4b0 Jun 15, 2026
20 checks passed
@github-actions github-actions Bot removed the Needs Second Approval Has one approval, one more approval to merge label Jun 15, 2026
@github-actions github-actions Bot added this to the 2.25 release milestone Jun 15, 2026
@david-allison
david-allison deleted the limits-map-1 branch June 15, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants