Description:When the alert_rules is deleted or does not exist (data migration scene), the recovery error 404 causes the program to stop.
Bug reproduction steps
Use Grafana backup restore error and terminate program execution
[DEBUG] resp status: 404
The response text is empty.
[DEBUG] resp body except:
Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\Scripts\grafana-backup.exe\__main__.py", line 7, in <module>
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\grafana_backup\cli.py", line 55, in main
restore(args, settings)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\grafana_backup\restore.py", line 107, in main
restore_components(args, settings, restore_functions, tmpdir)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\grafana_backup\restore.py", line 132, in restore_components
restore_functions[ext[:-1]](args, settings, file_path)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\grafana_backup\create_alert_rule.py", line 40, in main
get_response= get_alert_rule(uid, grafana_url, http_get_headers, verify_ssl, client_cert, debug)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\grafana_backup\dashboardApi.py", line 208, in get_alert_rule
return send_grafana_get(url, http_get_headers, verify_ssl, client_cert, debug)
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\grafana_backup\dashboardApi.py", line 520, in send_grafana_get
json_data = r.json()
File "c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Bug Cause Analysis
The 'r.json' function in the 'send_grafana_get' method failed to JSON 404 data and did not correctly throw an exception, resulting in the program being unable to continue executing
Description:When the alert_rules is deleted or does not exist (data migration scene), the recovery error 404 causes the program to stop. Bug reproduction steps
Bug Cause Analysis The 'r.json' function in the 'send_grafana_get' method failed to JSON 404 data and did not correctly throw an exception, resulting in the program being unable to continue executing