-
Notifications
You must be signed in to change notification settings - Fork 174
Open
Description
Basically the same situation as #1827 except that I had an API key filled in, but then generated a new API key in PyMedusa, and then I saw this error in SabNZB:
Traceback (most recent call last):
File "/usr/share/nzbget/ppscripts/nzbToSickBeard.py", line 278, in <module>
result = nzbToMedia.main(sys.argv, section)
File "/usr/share/nzbget/ppscripts/nzbToMedia.py", line 763, in main
result = sab.process_script()
File "/usr/share/nzbget/ppscripts/core/processor/sab.py", line 13, in process_script
return nzb.process(
~~~~~~~~~~~^
input_directory=os.environ['SAB_COMPLETE_DIR'],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
failure_link=os.environ['SAB_FAILURE_URL'],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/share/nzbget/ppscripts/core/processor/nzb.py", line 127, in process
result = tv.process(section_name, input_directory, input_name, status, client_agent, download_id, input_category, failure_link)
File "/usr/share/nzbget/ppscripts/core/auto_process/tv.py", line 337, in process
return init_sickbeard.fork_obj.api_call()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/share/nzbget/ppscripts/core/auto_process/managers/pymedusa.py", line 122, in api_call
if not jdata.get('status') or not jdata['status'] == 'success':
^^^^^
UnboundLocalError: cannot access local variable 'jdata' where it is not associated with a value
I think it would be good to add error handling to the request itself. If a bad auth token (or bad api key) is used, the PyMedusa v2 api returns HTTP 401 along with a response body of {"error": "No authorization token."}
. I think a reasonable way to do error handling generically would be to catch any non-HTTP 200 responses and who the HTTP response code number along with the response body. That way the Sickbeard fork is responsible for presenting a reasonable error message and users aren't shown an uncaught exception that isn't descriptive of the problem.
Metadata
Metadata
Assignees
Labels
No labels