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

Handle RequestsJSONDecodeError exceptions #256

Open
nemobis opened this issue Jan 19, 2024 · 0 comments
Open

Handle RequestsJSONDecodeError exceptions #256

nemobis opened this issue Jan 19, 2024 · 0 comments

Comments

@nemobis
Copy link

nemobis commented Jan 19, 2024

I'm using the latest grafana-backup with Grafana v10.0.2. A vanilla grafana-backup save downloads a few dashboards but then crashes on one of them (I think the URL might have been redirected somewhere else). It would be nice to just skip upon such errors.


Traceback (most recent call last):
  File "/home/federico/.local/bin/grafana-backup", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/cli.py", line 52, in main
    save(args, settings)
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/save.py", line 70, in main
    backup_functions[backup_function](args, settings)
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/save_dashboards.py", line 27, in main
    save_dashboards_above_Ver6_2(folder_path, log_file, grafana_url, http_get_headers, verify_ssl, client_cert, debug, pretty_print, uid_support, uid_dashboard_slug_suffix)
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/save_dashboards.py", line 100, in save_dashboards_above_Ver6_2
    get_individual_dashboard_setting_and_save(dashboards, folder_path, log_file, grafana_url, http_get_headers, verify_ssl, client_cert, debug, pretty_print, uid_support, slug_suffix)
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/save_dashboards.py", line 65, in get_individual_dashboard_setting_and_save
    (status, content) = get_dashboard(board_uri, grafana_url, http_get_headers, verify_ssl, client_cert, debug)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/dashboardApi.py", line 125, in get_dashboard
    (status_code, content) = send_grafana_get(
                             ^^^^^^^^^^^^^^^^^
  File "/home/federico/.local/lib/python3.12/site-packages/grafana_backup/dashboardApi.py", line 515, in send_grafana_get
    return (r.status_code, r.json())
                           ^^^^^^^^
  File "/usr/lib/python3.12/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)

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