@dae is this something that needs to be updated again? I can’t reproduce it myself yet, but multiple others have had this issue
UPDATE: I’ve now had 5-6 people email me with the same issue. They seem to be able to use special fields just fine on 2.1.26. This issue occurs when importing a brand new deck and if they switch profiles, they can import fine without any issues. Turning all add-ons off except for special fields does not solve the problem. I have no idea what the issue is. If the add-on needs to be updated, please let me know and I’ll talk with John and/or @Arthur
Assuming it only happens when the add-on is active, then it does look like it needs to be updated - it appears to be saving an old version of a note type that something else already modified.
Edit: note that this issue likely existed in .28 and .29 as well - I don’t think any recent changes would have suddenly broken this.
Erro
Ocorreu um erro. Por favor, vá para Ferramentas > Verificar Banco de Dados para ver se isso corrige o problema.
Se o problema persistir, por favor relate-o em nossa página de ajuda. Copie e cole a informação abaixo dentro de seu relatório.
Anki 2.1.30 (06a69c25) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 10
Flags: frz=True ao=False sv=1
Add-ons, last update check: 2020-08-12 20:32:11
Caught exception:
Traceback (most recent call last):
File “aqt\webview.py”, line 493, in handler
File “aqt\editor.py”, line 485, in
File “aqt\addcards.py”, line 189, in _addCards
File “aqt\editor.py”, line 597, in saveAddModeVars
File “anki\models.py”, line 87, in save
File “anki\models.py”, line 231, in update
File “anki\rsbackend_gen.py”, line 414, in add_or_update_notetype
File “anki\rsbackend.py”, line 265, in _run_command
anki.rsbackend.InvalidInput: InvalidInput { info: “attempt to save stale notetype” }
Import failed. Debugging info:
Traceback (most recent call last):
File “aqt/importing.py”, line 403, in on_done
File “concurrent/futures/_base.py”, line 432, in result
File “concurrent/futures/_base.py”, line 388, in __get_result
File “concurrent/futures/thread.py”, line 57, in run
File “anki/importing/apkg.py”, line 44, in run
File “anki/importing/anki2.py”, line 41, in run
File “anki/importing/anki2.py”, line 64, in _import
File “/Users/matthewgoldman/Library/Application Support/Anki2/addons21/1102281552/init.py”, line 72, in newImportNotes
shouldAdd = self._uniquifyNote(note)
File “anki/importing/anki2.py”, line 189, in _uniquifyNote
File “/Users/matthewgoldman/Library/Application Support/Anki2/addons21/1102281552/init.py”, line 255, in _mid
self.dst.models.update(model)
File “anki/models.py”, line 231, in update
File “anki/rsbackend_gen.py”, line 414, in add_or_update_notetype
File “anki/rsbackend.py”, line 265, in _run_command
anki.rsbackend.InvalidInput: InvalidInput { info: “attempt to save stale notetype” }
Hi,
My anki collection has lots of cards already, but I wanted to add another deck.
However, when I try to add this deck, I get the following error:
Import failed. Debugging info:
Traceback (most recent call last):
File “aqt\importing.py”, line 404, in on_done
File “concurrent\futures_base.py”, line 432, in result
File “concurrent\futures_base.py”, line 388, in __get_result
File “concurrent\futures\thread.py”, line 57, in run
File “lib\site-packages\anki\importing\apkg.py”, line 44, in run
File “lib\site-packages\anki\importing\anki2.py”, line 41, in run
File “lib\site-packages\anki\importing\anki2.py”, line 64, in import
File "C:\Users\Savage Unicorn\AppData\Roaming\Anki2\addons21\1102281552_init.py", line 72, in newImportNotes
shouldAdd = self._uniquifyNote(note)
File “lib\site-packages\anki\importing\anki2.py”, line 189, in uniquifyNote
File "C:\Users\Savage Unicorn\AppData\Roaming\Anki2\addons21\1102281552_init.py", line 255, in _mid
self.dst.models.update(model)
File “lib\site-packages\anki\models.py”, line 231, in update
File “lib\site-packages\anki\rsbackend_gen.py”, line 414, in add_or_update_notetype
File “lib\site-packages\anki\rsbackend.py”, line 265, in _run_command
anki.rsbackend.InvalidInput: InvalidInput { info: “attempt to save stale notetype” }
If I add the same deck to an empty new anki profile, there are no problems. So I am assuming something is conflicting with the currenty profile / cards I have.
Can you help me figure out what may be wrong?
Thank you.
try temporarily disabling all add-ons and then add the deck you want.
to temporarily disable all add-ons you can hold down shift key while starting the app.
if you were able to add the deck, then an add-on (special fields probably) is causing this error.
It looks like this occurs in .28 and .29 and happens when you have a more recent version of the note type and try to import and older version of the same note type. Do you have any recommendations on what needs to be updated on the add-on? I have not heard back from John Pincock yet, but I’m getting a few emails a day about this error causing panic for many med students. If not, no worries!
Do you have any plans to incorporate Arthur’s PR anytime soon for this? We plan to be seriously delving into the updating and collaboration side of things in the near future as @andrewsanchez previously messaged you about.
So I am quite a newb when it comes to the data model and haven’t dug into the internals with note types, importing, etc., but it looks like this might be a simple fix:
The Special Fields add-on overrides the _mid method of the Anki2Importer object like so (docstrings removed):
def _mid(self, srcMid):
if srcMid in self._modelMap:
return self._modelMap[srcMid]
mid = srcMid
srcModel = self.src.models.get(srcMid)
srcScm = self.src.models.scmhash(srcModel)
updateNoteType = getUserOptionSpecial("update note styling")
while True:
if not self.dst.models.have(mid):
model = srcModel.copy()
model["id"] = mid
model["usn"] = self.col.usn()
self.dst.models.update(model)
break
dstModel = self.dst.models.get(mid)
dstScm = self.dst.models.scmhash(dstModel)
if srcScm == dstScm:
if updateNoteType or (updateNoteType is None and srcModel["mod"] > dstModel["mod"]):
model = srcModel.copy()
model["id"] = mid
model["usn"] = self.col.usn()
self.dst.models.update(model)
break
mid += 1
self._modelMap[srcMid] = mid
return mid
If I understand correctly, the need is for users to override Anki’s guard against updating a note from another note that has an older time stamp. The bug is a result of the add-on passing models into Anki2Importer.dst.models.update which have an older modification time than the note which is to be updated. Is it true that, while this behavior was no allowed previously, it wasn’t strictly enforced anywhere, hence the recent surge of error reports? A quick and dirty patch for the Special Fields add-on could be:
modified Specialfields21/__init__.py
@@ -250,6 +250,7 @@ def _mid(self, srcMid):
# copy styling changes over if newer
if updateNoteType or (updateNoteType is None and srcModel["mod"] > dstModel["mod"]):
model = srcModel.copy()
+ model["mod"] = max(srcModel["mod"], dstModel["mod"])
model["id"] = mid
model["usn"] = self.col.usn()
self.dst.models.update(model)
I saw quick and dirty because this clearly contradicts the logic in that parenthetical part of the this branch, so hopefully we can summon @ArthurMilchior to see what he thinks.
Questions:
Do we actually want to let people do this? Is this the right way to allow it? Is there a better way?
Please excuse my ignorance of both the special fields add-on and the relevant Anki internals. I just wanted to report my findings ASAP before other people burn time on this
@dae it appears this is a fix and the add-on has been updated. I’d still be curious when you’re thinking about looking more into Arthur’s PR though if you have a minute
@andrewsanchez since the code is checking to make sure the schemas match first, that looks like it’ll do the job - the mtime check is to ensure a stale note type with different fields is not accidentally saved, breaking notes.
@AnKingMed once remaining issues have been ironed out of the current stable release, scheduling is likely to be the next thing on the list. Import/export work will likely come after that.
@andrewsanchez I don’t really get what you want me to answer. Seems you got it right. Congratulation !
The AnKing contacted me. And I was less useful. I understood that it was a problem with trying to update with an older model. Your solution makes a lot of sens.
At best, I would simply state that i’d have done:
if srcModel["mod"] < dstModel["mod"]:
model["mod"] = dstModel["mod"] + 1
so that it is absolutely sure that the srcModel is considered the most recent one. During sync, it would ensure that the update occurs in the correct sens I hope. I honestly don’t know what occurs if “mod” is not changed and the schema is changed; that is not supposed to happen. But it may well create no problem at all.
I’m getting this Same error code but I’m not understanding how to fix it. I have the new anki version as I had to buy a new laptop & an older deck so the error code keeps popping up
Hello! I ended up getting the same error and also am not sure how to fix it. I have deleted and redownloaded the special fields add on multiple times and still keep getting the import failed debugging info error. Please let me know if there is anything else I can do!