Bug 1121799 - [abrt] anki: collection.py:178:modSchema:AnkiError: abortSchemaMod
Summary: [abrt] anki: collection.py:178:modSchema:AnkiError: abortSchemaMod
Alias: None
Product: Fedora
Classification: Fedora
Component: anki
Version: 20
Hardware: x86_64
OS: Unspecified
Target Milestone: ---
Assignee: Christian Krause
QA Contact: Fedora Extras Quality Assurance
URL: https://retrace.fedoraproject.org/faf...
Whiteboard: abrt_hash:12e5e9b4a98c486ef286b5e4c22...
Depends On:
TreeView+ depends on / blocked
Reported: 2014-07-21 22:15 UTC by Tim Waugh
Modified: 2014-11-13 09:02 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2014-11-12 20:16:51 UTC

Attachments (Terms of Use)
File: backtrace (526 bytes, text/plain)
2014-07-21 22:15 UTC, Tim Waugh
no flags Details
File: environ (1.47 KB, text/plain)
2014-07-21 22:15 UTC, Tim Waugh
no flags Details
untested patch (905 bytes, patch)
2014-07-31 08:25 UTC, Tim Waugh
no flags Details | Diff

Description Tim Waugh 2014-07-21 22:15:04 UTC
Description of problem:
Answered 'No' to a dialog that appeared when clicking the '+' button in the Card Types dialog.

Version-Release number of selected component:

Additional info:
reporter:       libreport-2.2.2
cmdline:        python /usr/bin/anki
executable:     /usr/bin/anki
kernel:         3.15.5-200.fc20.x86_64
runlevel:       N 5
type:           Python
uid:            1001

Truncated backtrace:
collection.py:178:modSchema:AnkiError: abortSchemaMod

Traceback (most recent call last):
  File "/usr/share/anki/aqt/clayout.py", line 309, in onAddCard
    self.mm.addTemplate(self.model, t)
  File "/usr/share/anki/anki/models.py", line 350, in addTemplate
  File "/usr/share/anki/anki/collection.py", line 178, in modSchema
    raise AnkiError("abortSchemaMod")
AnkiError: abortSchemaMod

Local variables in innermost frame:
self: <anki.collection._Collection object at 0x7f6d34084050>
check: True

Comment 1 Tim Waugh 2014-07-21 22:15:07 UTC
Created attachment 919774 [details]
File: backtrace

Comment 2 Tim Waugh 2014-07-21 22:15:08 UTC
Created attachment 919775 [details]
File: environ

Comment 3 Christian Krause 2014-07-30 20:08:54 UTC
I've tried it for my decks, but so far it doesn't happen for me.

If you can reproduce the issue, please can you provide some detailed step-by-step instructions? Thanks!

Comment 4 Tim Waugh 2014-07-31 08:24:06 UTC
It's from aqt/main.py:AnkiQt:onSchemaMod():

    def onSchemaMod(self, arg):
        # if triggered in sync, make sure we don't use the gui
        if not self.inMainThread():
            return True
        # if from the full sync menu, ignore
        if self.hideSchemaMsg:
            return True
        return askUser(_("""\
The requested change will require a full upload of the database when \
you next synchronize your collection. If you have reviews or other changes \
waiting on another device that haven't been synchronized here yet, they \
will be lost. Continue?"""))

Answering 'no' to this dialog results in the caller (collection.py:_Collection:modSchema()) raising an exception:

    def modSchema(self, check=True):
        "Mark schema modified. Call this first so user can abort if necessary."
        if not self.schemaChanged():
            if check and not runFilter("modSchema", True):
                raise AnkiError("abortSchemaMod")
        self.scm = intTime(1000)

but models.py:ModelManager:addTemplate() doesn't catch it:

    def addTemplate(self, m, template):
        "Note: should col.genCards() afterwards."
        if m['id']:
            self.col.modSchema()     <---------- here

In fact, this is the only place in the code that uses AnkiError at all.

At some level, there needs to be a try:...except AnkiError: wrapped around this call. Judging from where DeckRenameError is caught, it should probably be at the aqt level.

Comment 5 Tim Waugh 2014-07-31 08:25:12 UTC
Created attachment 922854 [details]
untested patch

Here's a patch that does that (against current git master). I don't know enough about Anki internals to know if it makes sense.

Comment 6 Christian Krause 2014-11-12 20:16:51 UTC
I have asked the upstream developer about his opinion, but there was some reluctance to take that patch.

Unfortunately, I can't reproduce the problem and I'm not familiar enough with the code to judge the correctness of the patch (sure, it looks reasonable).

I'm afraid I don't have a better solution besides asking you to report the problem directly to upstream:


I'm closing this bug report as "UPSTREAM" for now.

If you can provide step-by-step instructions how to reproduce the issue (based on an empty deck), then I would be happy to test and apply the patch and to report the concrete issue upstream by myself. In that case, please attach the information and re-open the bug.

Thanks for you understanding.

Comment 7 Tim Waugh 2014-11-13 09:02:02 UTC
Here's how to reproduce it:

Start anki
Select language (e.g. English)
Confirm language(!)
Click the 'sync' button and enter your AnkiWeb ID and password
Wait for it to synchronise
Find and download any shared deck
Click Add
Click Cards...
Click '+' (top right corner)
Answer 'No' to the dialog

Note You need to log in before you can comment on or make changes to this bug.