themoeway / local-audio-yomichan

Anki add-on to run a local audio server for Yomichan.
MIT License
91 stars 11 forks source link

400 style errors cause pop-up in Anki, return 400 or log to file, but don't break or show error pop-up #17

Open kanjieater opened 1 year ago

kanjieater commented 1 year ago

I'm running into this error with the backfill add-on (and some custom code to automate it when adding new cards.

I'm getting this error as a popup multiple times when calling the server. My request would be to treat this like a standard server 400 level error and let clients handle malformed input on their side, instead of blocking the main anki app's UI.

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.66 (70506aeb) Python 3.9.15 Qt 5.15.2 PyQt 5.15.5
Platform: Windows-10-10.0.22621
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-09-08 13:31:51
Add-ons possibly involved: ⁨Local Audio Server for Yomichan⁩

----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62031)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\[server.py](http://server.py/)", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=nhk16&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62032)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=shinmeikai8&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62033)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod_alternate&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62034)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62036)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=nhk16&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62037)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=shinmeikai8&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62038)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod_alternate&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62039)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62041)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=nhk16&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62042)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=shinmeikai8&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62043)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod_alternate&term=&reading=
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 62044)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod&term=&reading=
----------------------------------------

It seems like bad html in the fields can mess with it too:

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.66 (70506aeb) Python 3.9.15 Qt 5.15.2 PyQt 5.15.5
Platform: Windows-10-10.0.22621
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-09-09 17:16:17
Add-ons possibly involved: ⁨Local Audio Server for Yomichan⁩

----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 61904)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=nhk16&term= %E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE&reading=%E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 61905)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=shinmeikai8&term= %E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE&reading=%E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 61906)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod_alternate&term= %E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE&reading=%E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 61907)
Traceback (most recent call last):
  File "socketserver", line 683, in process_request_thread
  File "socketserver", line 360, in finish_request
  File "http.server", line 658, in __init__
  File "socketserver", line 747, in __init__
  File "http.server", line 432, in handle
  File "http.server", line 420, in handle_one_request
  File "F:\Anki2\addons21\1045800357\server.py", line 166, in do_GET
    qcomps = self.parse_query_components()
  File "F:\Anki2\addons21\1045800357\server.py", line 107, in parse_query_components
    raise Exception(f"Cannot find term or expression in query: {self.path}")
Exception: Cannot find term or expression in query: /?sources=jpod&term= %E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE&reading=%E3%81%9B%E3%82%81%E3%81%A6%E3%82%82%E3%81%AE
----------------------------------------