ysde/grafana-backup-tool

requests.exceptions.JSONDecodeError

Opened this issue · 1 comments

When I do the backup locally I met this issue on my local M1 Mac?
window.onload = function() {
var preloader = document.getElementsByClassName("preloader");
if (preloader.length) {
preloader[0].className = "preloader preloader--done";
}
};
</script>

<script src="public/build/runtime.b5d3c4da30d141a6181f.js" type="text/javascript"></script>
<script src="public/build/angular~app.b5d3c4da30d141a6181f.js" type="text/javascript"></script>
<script src="public/build/app.b5d3c4da30d141a6181f.js" type="text/javascript"></script>
<script src="public/build/moment~app.b5d3c4da30d141a6181f.js" type="text/javascript"></script>
<script src="public/build/vendors~app.b5d3c4da30d141a6181f.js" type="text/javascript"></script>
<script>
  performance.mark('js done blocking');
</script>

Traceback (most recent call last):
File "/opt/homebrew/lib/python3.10/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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 "/opt/homebrew/bin/grafana-backup", line 8, in
sys.exit(main())
File "/opt/homebrew/lib/python3.10/site-packages/grafana_backup/cli.py", line 52, in main
save(args, settings)
File "/opt/homebrew/lib/python3.10/site-packages/grafana_backup/save.py", line 61, in main
backup_functions[backup_function](args, settings)
File "/opt/homebrew/lib/python3.10/site-packages/grafana_backup/save_library_elements.py", line 22, in main
library_elements = get_all_library_elements_in_grafana(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
File "/opt/homebrew/lib/python3.10/site-packages/grafana_backup/save_library_elements.py", line 28, in get_all_library_elements_in_grafana
(status, content) = search_library_elements(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
File "/opt/homebrew/lib/python3.10/site-packages/grafana_backup/dashboardApi.py", line 112, in search_library_elements
return send_grafana_get(url, http_get_headers, verify_ssl, client_cert, debug)
File "/opt/homebrew/lib/python3.10/site-packages/grafana_backup/dashboardApi.py", line 448, in send_grafana_get
return (r.status_code, r.json())
File "/opt/homebrew/lib/python3.10/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)

I had a similar case.
Check whether you have a trailing slash in the Grafana URL setting.
This will cause the /api/health endpoint to fail.
Also referring to the Documentation:

### Do not use a trailing slash on GRAFANA_URL  
export GRAFANA_URL=http://some.host.org:3000