Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug:When the alert_rules is deleted or does not exist (data migration scene), the recovery error 404 causes the program to stop #277

Open
nwzq972476 opened this issue Aug 22, 2024 · 0 comments

Comments

@nwzq972476
Copy link

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

  1. Build a new Grafana in the Windows environment
  2. Create an alarm rule within it
  3. Use Grafana backup save to backup the entire data
  4. Grafana backup restore full recovery, successful
  5. Call the interface( http://localhost:3000/api/v1/provisioning/alert -Delete alarm rule (rules/ddvjzl8tjlgxsa)
  6. 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

@nwzq972476 nwzq972476 changed the title Fix-Bug:When the alert_rules is deleted or does not exist (data migration scene), the recovery error 404 causes the program to stop Bug:When the alert_rules is deleted or does not exist (data migration scene), the recovery error 404 causes the program to stop Aug 22, 2024
nwzq972476 added a commit to nwzq972476/grafana-backup-tool that referenced this issue Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant