Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Card template ⁨1⁩ in notetype '⁨[…]' has a problem.” #200

Open
galantra opened this issue Jul 10, 2023 · 1 comment
Open

“Card template ⁨1⁩ in notetype '⁨[…]' has a problem.” #200

galantra opened this issue Jul 10, 2023 · 1 comment

Comments

@galantra
Copy link

galantra commented Jul 10, 2023

Hi, I got an error message when creating a snapshot. It seems like CrowdAnki can not handle this situation and stops creating the snapshot.

Error message

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 2.1.65 (aa9a734f) Python 3.9.15 Qt 6.4.3 PyQt 6.4.0
Platform: Windows-10-10.0.19045
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-07-10 08:21:48

Caught exception:


Traceback (most recent call last):
  File "aqt.main", line 538, in unloadProfileAndShowProfileManager
  File "aqt.main", line 510, in unloadProfile
  File "_aqt.hooks", line 3916, in __call__
  File "anki.hooks", line 34, in runHook
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\history\archiver_vendor.py", line 42, in snapshot_on_sync
    self.do_snapshot('CrowdAnki: Snapshot on sync')
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\history\archiver_vendor.py", line 50, in do_snapshot
    self.all_deck_archiver().archive(overrides=self.overrides(),
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\history\archiver.py", line 23, in archive
    self.deck_archiver_supplier(deck).archive(reason=reason)
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\history\anki_deck_archiver.py", line 19, in archive
    deck_path = self.deck_exporter.export_to_directory(self.deck, self.output_directory)
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\export\anki_exporter.py", line 51, in export_to_directory
    self._save_changes(deck)
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\export\anki_exporter.py", line 80, in _save_changes
    self.collection.models.save(model.anki_dict)
  File "anki.models", line 569, in save
  File "anki.models", line 552, in update
  File "anki._backend_generated", line 873, in add_or_update_notetype
  File "anki._backend", line 156, in _run_command
anki.errors.CardTypeError: Card template ⁨1⁩ in notetype '⁨2. Mnemonics-fd161⁩' has a problem.<br>See the preview for more information.

Perhaps it's possible to tell CrowdAnki to ignore such errors and complete the snapshot?

@aplaice
Copy link
Collaborator

aplaice commented Jul 26, 2023

Thanks for the bug report and sorry for the very late reply!

I'm not sure when (in terms of the underlying cause) this might occur. Anki seems to call the error here, but I haven't looked closely at the code to determine the causes.

Does this happen frequently?

Given that saving the note model after export is relatively important (it helps avoid various issues, for instance, off the top of my head, duplicate UUIDs), I'd rather not make CrowdAnki ignore errors raised by Anki, at least not without a very good understanding of when/why they happen, and even then only behind an option.

You can make CrowdAnki ignore the errors locally by patching C:\Users\user\AppData\Roaming\Anki2\addons21\1788670778\export\anki_exporter.py:

7a8
> from anki.errors import CardTypeError
80c81,84
<                 self.collection.models.save(model.anki_dict)
---
>                 try:
>                     self.collection.models.save(model.anki_dict)
>                 except CardTypeError as e:
>                     print(e)

i.e. add:

from anki.errors import CardTypeError

to the header and change:

                 self.collection.models.save(model.anki_dict)

to:

                try:
                    self.collection.models.save(model.anki_dict)
                except CardTypeError as e:
                    print(e)

(Clearly, this has the disadvantage that the changes will be undone when you upgrade CrowdAnki.)

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

No branches or pull requests

2 participants