Summary
When Yomitan calls notesInfo, AnkiConnect Android returns a response where the cards field is undefined. Yomitan's response validator expects cards: number[] and throws, which suppresses the Anki buttons in the popup for the looked-up word.
This triggers whenever Yomitan's preceding findNotes call returns at least one matching note ID, which happens both for words already added as notes and for words whose lookup string appears anywhere in the field content of any existing note. As J-J card definitions accumulate, the latter case becomes increasingly common.
Environment
- AnkiConnect Android: v1.15
- Yomitan: 26.4.6.0
- Browser: Firefox for Android
- AnkiDroid: 2.23.3
- Android: 16
Steps to reproduce
- Have at least one note in your collection. Either add the lookup word itself, or have any existing note whose fields contain the lookup string somewhere (e.g., a J-J definition that mentions the word).
- Look up that word in Yomitan.
- Open
about:debugging from desktop Firefox, attach to the Yomitan extension on the phone, and watch the console.
Reproduced with three lookups:
- 泣き (added as a note in my deck)
- 身柄 (not added; appears in the back-side J-J definition of my 逮捕 card: 「…身体に直接力を加えて身柄を拘束すること…」)
- 頭髪 (not added; appears in the field content of two existing notes)
All three produce the same error.
Expected
Anki buttons render in the Yomitan popup with the appropriate duplicate-state indicator.
Actual
No Anki buttons render. Yomitan logs:
Yomitan Popup Dictionary 26.4.6.0 has encountered a problem.
Originating URL: moz-extension://.../popup.html?type=terms&query=%E6%B3%A3%E3%81%8D&wildcards=off
ExtensionError: Unexpected type, field cards: expected number[], received undefined
_createError@.../js/comm/anki-connect.js:596:23
_createUnexpectedResultError@.../js/comm/anki-connect.js:608:21
_normalizeArray@.../js/comm/anki-connect.js:631:24
_normalizeNoteInfoArray@.../js/comm/anki-connect.js:677:58
notesInfo@.../js/comm/anki-connect.js:191:21
_notesCardsInfo@.../js/background/backend.js:758:44
_onApiGetAnkiNoteInfo@.../js/background/backend.js:738:108
Lookups whose query string does not appear anywhere in any existing note do not trigger this — in those cases findNotes returns an empty list, notesInfo is called with no IDs, and there is no cards field for the validator to reject.
Likely cause
The NoteInfo class in app/src/main/java/com/kamwithk/ankiconnectandroid/ankidroid_api/NoteAPI.java (release 1.15, lines 141-170) declares only noteId, modelName, tags, and fields. Desktop AnkiConnect's notesInfo response also includes a cards array of card IDs per note (select id from cards where nid = ? order by ord in the desktop plugin), which Yomitan's _normalizeNoteInfoArray validator enforces.
The card IDs are available through AnkiDroid's public ContentProvider API — FlashCardsContract.Card._ID is documented as the card's database ID, and IntegratedAPI.isNoteInDeck already queries Uri.withAppendedPath(noteUri, "cards") (just with a different projection). Extending that pattern in notesInfo and adding a cards field to NoteInfo should resolve the validation failure.
Summary
When Yomitan calls
notesInfo, AnkiConnect Android returns a response where thecardsfield isundefined. Yomitan's response validator expectscards: number[]and throws, which suppresses the Anki buttons in the popup for the looked-up word.This triggers whenever Yomitan's preceding
findNotescall returns at least one matching note ID, which happens both for words already added as notes and for words whose lookup string appears anywhere in the field content of any existing note. As J-J card definitions accumulate, the latter case becomes increasingly common.Environment
Steps to reproduce
about:debuggingfrom desktop Firefox, attach to the Yomitan extension on the phone, and watch the console.Reproduced with three lookups:
All three produce the same error.
Expected
Anki buttons render in the Yomitan popup with the appropriate duplicate-state indicator.
Actual
No Anki buttons render. Yomitan logs:
Lookups whose query string does not appear anywhere in any existing note do not trigger this — in those cases
findNotesreturns an empty list,notesInfois called with no IDs, and there is nocardsfield for the validator to reject.Likely cause
The
NoteInfoclass inapp/src/main/java/com/kamwithk/ankiconnectandroid/ankidroid_api/NoteAPI.java(release 1.15, lines 141-170) declares onlynoteId,modelName,tags, andfields. Desktop AnkiConnect'snotesInforesponse also includes acardsarray of card IDs per note (select id from cards where nid = ? order by ordin the desktop plugin), which Yomitan's_normalizeNoteInfoArrayvalidator enforces.The card IDs are available through AnkiDroid's public ContentProvider API —
FlashCardsContract.Card._IDis documented as the card's database ID, andIntegratedAPI.isNoteInDeckalready queriesUri.withAppendedPath(noteUri, "cards")(just with a different projection). Extending that pattern innotesInfoand adding acardsfield toNoteInfoshould resolve the validation failure.