Oh no an error occurred

Before the error happened, I was editing cards and then synced my collection
[Replace this text.]

Error message (don't change this)
Anki 2.1.63 (f356f177) Python 3.9.15 Qt 6.5.0 PyQt 6.5.0
Platform: macOS-13.4.1-arm64-arm-64bit
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2023-08-16 23:23:55

Traceback (most recent call last):

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/importing.py", line 329, in _update_or_create_note_inner
    note = aqt.mw.col.get_note(id=NoteId(note_data.anki_nid))

  File "anki.collection", line 527, in get_note

  File "anki.notes", line 49, in __init__

  File "anki.notes", line 55, in load

  File "anki._backend_generated", line 653, in get_note

  File "anki._backend", line 156, in _run_command

anki.errors.NotFoundError: Your database appears to be in an inconsistent state. Please use the Check Database action.


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "aqt.taskman", line 122, in _on_closures_pending

  File "aqt.taskman", line 71, in <lambda>

  File "aqt.taskman", line 90, in wrapped_done

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/operations/ankihub_sync.py", line 39, in on_sync_done
    on_done(future_with_exception(future.exception()))

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/auto_sync.py", line 74, in sync_with_ankiweb
    future.result()

  File "concurrent.futures._base", line 439, in result

  File "concurrent.futures._base", line 391, in __get_result

  File "concurrent.futures.thread", line 58, in run

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/operations/ankihub_sync.py", line 32, in <lambda>
    task=lambda: ah_deck_updater.update_decks_and_media(to_sync_ah_dids),

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/deck_updater.py", line 45, in update_decks_and_media
    self._update_decks(ah_dids)

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/deck_updater.py", line 68, in _update_decks
    should_continue = self._update_single_deck(ah_did)

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/deck_updater.py", line 80, in _update_single_deck
    result = self._download_updates_for_deck(ankihub_did)

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/gui/deck_updater.py", line 117, in _download_updates_for_deck
    import_result = self._importer.import_ankihub_deck(

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/importing.py", line 101, in import_ankihub_deck
    return self._import_ankihub_deck_inner(

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/importing.py", line 150, in _import_ankihub_deck_inner
    dids = self._import_notes(

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/importing.py", line 198, in _import_notes
    note = self._update_or_create_note(

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/importing.py", line 277, in _update_or_create_note
    note = self._update_or_create_note_inner(

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/importing.py", line 354, in _update_or_create_note_inner
    note = create_note_with_id(

  File "/Users/timothydo/Library/Application Support/Anki2/addons21/1322529746/main/utils.py", line 90, in create_note_with_id
    aqt.mw.col.db.execute(f"UPDATE notes SET id={anki_id} WHERE id={note.id};")

  File "anki.dbproxy", line 67, in all

  File "anki.dbproxy", line 61, in _query

  File "anki._backend", line 92, in db_query

  File "anki._backend", line 116, in _db_command

anki.errors.DBError: DbError { info: "SqliteFailure(Error { code: ConstraintViolation, extended_code: 1555 }, Some(\"UNIQUE constraint failed: notes.id\"))", kind: Other }

Sentry link (for developers)

Can you go to tools → check database?

if it still occurs, can you delete the ankihub addon and reinstall

It might be a new issue in the add-on. @TimothyDo5 if Check Database didn’t help, can you use AnkiHub → Help → Upload logs and data and let use know the filename shown?

1 Like

ankihub_addon_debug_info_d712d_1692276060.zip

Here is the filename. Thank you guys so much for everything you do!

1 Like

I didn’t get the error testing with your collection, but the issue is caused by two notes having the same ID for some reason. Try searching for nid:1484768396948 in the browser.

Tools > Check Database will fix the issue by giving one note a different ID, though. Are you still getting the error?

I just pushed that new card yesterday, I double checked and it has two separate NIDs, so probably something user-related and not AnkiHub-related I’m assuming

Original card nid: 1484768396947
New card nid: 1484768396948 (basically +1)