FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.94k stars 219 forks source link

Error Using AnkiConnect - using mpvacious, VocabSieve, and other language learning apps to make Anki flashcards from videos #316

Open mattbowlby opened 2 years ago

mattbowlby commented 2 years ago

I have installed AnkiConnect, but it doesn't seem to work when attempting to add new flashcards. AnkiConnect v.6 shows it is working at http://localhost:8765/. I am using macOS and I get the error message below:

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 on the add-on support site.
Debug info:
Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-04-30 14:46:27
Add-ons possibly involved: ⁨AnkiConnect⁩

Caught exception:
Traceback (most recent call last):
  File "/Users/matt/Library/Application Support/Anki2/addons21/2055492159/__init__.py", line 96, in advance
    self.server.advance()
  File "/Users/matt/Library/Application Support/Anki2/addons21/2055492159/web.py", line 135, in advance
    self.advanceClients()
  File "/Users/matt/Library/Application Support/Anki2/addons21/2055492159/web.py", line 150, in advanceClients
    self.clients = list(filter(lambda c: c.advance(), self.clients))
  File "/Users/matt/Library/Application Support/Anki2/addons21/2055492159/web.py", line 150, in <lambda>
    self.clients = list(filter(lambda c: c.advance(), self.clients))
  File "/Users/matt/Library/Application Support/Anki2/addons21/2055492159/web.py", line 67, in advance
    self.writeBuff += self.handler(req)
  File "/Users/matt/Library/Application Support/Anki2/addons21/2055492159/web.py", line 190, in handlerWrapper
    if params.get('action', '') == 'requestPermission':
UnboundLocalError: local variable 'params' referenced before assignment
nvlled commented 2 years ago

I have encountered this error as well. You may most likely have a malformed JSON body, or you failed to serialize your request body properly.

1over137 commented 2 years ago

VocabSieve author here. I have never seen this happening, and I am using the same versions (anki 2.1.49, newest AnkiConnect). Can you provide a way to reproduce this from a clean slate?

For reference, I am using the code on the Readme page for interfacing with AnkiConnect, and I have never encountered any error either in Anki or in VocabSieve.

@nvlled The functions handling Anki exports is in this file. Any potentially malformed JSONs here?

https://github.com/FreeLanguageTools/vocabsieve/blob/master/vocabsieve/tools.py

nvlled commented 2 years ago

@1over137 Oh, to be clear, I'm not using mpvacious or VocabSieve. I'm making an app that uses anki-connect, and I encountered the UnboundLocalError. I'll check the link anyway and see if I can find anything.