Run database check after receiving review error, but it still gives me the same error when reviewing a few cards

I’ve had these cards for quite some time. They just started erroring though and asking me to run the database check, which doesn’t fix the issue. I have disabled all extensions and still have the same issues. Collection for testing is being uploaded to here: https://drive.google.com/drive/folders/1Hopm8JHHdgrlK418FP4KgGTnrwmjsTXx?usp=drive_link

If I export only the problematic cards in “!優先__0 フィルターデッキ__0.Z 失敗したか?” that are failing the DB check (example: 落差 ) it doesn’t happen after the notes have been exported so I can’t reproduce with a smaller collection unfortunately.

エラー

エラーが発生しました。Shiftキーを押した状態でAnkiを起動してください。この操作により、インストールされているアドオンすべてが一時的に無効になります。

アドオンすべてを無効にすると問題が起こらなくなる場合、メニューの[ツール] > [アドオン] でアドオン管理画面を開き、アドオンを1つまたはいくつか無効にしてAnkiを再起動してみてください。この手順を繰り返し、問題を引き起こすアドオンを特定してください。

問題を引き起こすアドオンを特定できた際は、そのアドオンの作者に問題をご報告いただければ幸いです。

デバッグ情報:

Anki 23.10.1 (fac9e0ee) Python 3.9.15 Qt 5.15.2 PyQt 5.15.5

Platform: Windows-10-10.0.22621

Flags: frz=True ao=True sv=3

Add-ons, last update check: 2023-11-12 20:43:31

Caught exception:

Traceback (most recent call last):

File “aqt.taskman”, line 138, in _on_closures_pending

File “aqt.taskman”, line 82, in

File “aqt.taskman”, line 102, in wrapped_done

File “aqt.operations”, line 127, in wrapped_done

File “aqt.reviewer”, line 434, in after_answer

File “aqt.reviewer”, line 447, in _after_answering

File “aqt.reviewer”, line 227, in nextCard

File “aqt.reviewer”, line 243, in _get_next_v3_card

File “anki.scheduler.v3”, line 55, in get_queued_cards

File “anki._backend_generated”, line 675, in get_queued_cards

File “anki._backend”, line 158, in _run_command

anki.errors.NotFoundError: データベースが矛盾した状態にあるようです。[ツール] → [データベースをチェック] の操作を行ってください。

I tried to empty the filtered deck !優先__0 フィルターデッキ__0.Z 失敗したか? that the problematic cards showed up in, and unfortunately after rebuilding the deck won’t open.

Deleting or emptying the filtered deck, then using check database should fix it. The cards are pointing to an invalid deck.

Emptying filter deck & check db alone did not fix it unfortunately. I had to manually assign the unassigned cards to a deck. I’m not sure how it got into this bugged state, but it did fix it for now. Thank you for the help.

This bug keeps happening. The filtered deck is for some reason losing what deck the card is supposed to belong to. I’m not sure if it’s due to cards leeching in the filtered deck or undo-ing or something else.

If you can reproduce the issue when no add-ons are active, please provide the exact steps you’re taking so I can try to reproduce the issue.

I had to enable this line to fix the issue:
mw.col.sched.remFromDyn(cids)

I’m not sure why suspending or reset cards would automatically clear from dynamic/filtered decks before, but I think this was the issue. Thanks for the help Dae

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QAction
from anki.hooks import addHook
from aqt import mw
from aqt.utils import showInfo

from .utils import get_nids


MAX_LEECH_COUNT = 3
REMOVE_FLAGS = True


def resetSelectedCardScheduling(cids):
    """
    Resets statistics for selected cards,
    and removes them from learning queues.
    """
    # Removes card from dynamic deck
    mw.col.sched.remFromDyn(cids)
    # # Resets selected cards in current collection
    cards = [mw.col.getCard(cid) for cid in cids]
    cardFactors = [card.factor for card in cards]

    mw.col.sched.resetCards(cids)
    for card, factor in zip(cards, cardFactors):
        mw.col.db.execute("update cards set factor = ? where id = ?", factor, card.id)
    # showInfo(str(mw.col.getCard(1454585130840).factor))

    # # Removes card from learning queues
    # mw.col.sched.removeLrn(cids)
    # @@@@@@@@@@@@@@@@@@@@@@@@@@@ one of the commented lines above forces full sync :?
    mw.col.sched.unsuspendCards(cids)
    if REMOVE_FLAGS:
        mw.col.set_user_flag_for_cards(0, cids)

def get_leeches():
    query = f'tag:leech'
    return get_nids(query)

def handle_leech(nids=None, browser=None):
    mw.progress.start(label=f'Handling Leeches')
    if not nids or not browser:
        nids = get_leeches()

    for nid in nids:
        note = mw.col.getNote(nid)
        cids = [c.id for c in note.cards()]
        if note.hasTag('leech'):
            resetSelectedCardScheduling(cids)
            handle_tagging(note)
            note.flush()
    if browser:
        browser.model.reset()
        browser.mw.requireReset()
    mw.progress.finish()

def handle_max(n):
    max_tag = 'leech' + str(MAX_LEECH_COUNT)
    dead_tag = 'deadLeech' + str(MAX_LEECH_COUNT)
    if n.hasTag(dead_tag):
        return True
    if n.hasTag(max_tag):
        n.delTag(max_tag)
        n.addTag(dead_tag)
        return True
    return False


def handle_tagging(n):
    if not n.hasTag('leech'):
        return
    n.delTag("leech")
    n.delTag("重複0")
    tagged = False
    for i in range(MAX_LEECH_COUNT):
        original_tag = 'leech' + str(i)
        if n.hasTag(original_tag):
            n.delTag(original_tag)
            count = i + 1
            new_tag = 'leech' + str(count)
            n.addTag(new_tag)
            tagged = True
            break
    tagged = tagged or handle_max(n)
    if not tagged:
        n.addTag('leech0')

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.