From a0a0ab9375bc3fe90053de681a732175e6de4160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20REY?= Date: Sat, 4 Nov 2023 20:23:11 +0100 Subject: [PATCH] fix(folders): make sure to return a json response if Grafana returns an empty response Since Grafana 9.3 the folders endpoint stopped sending back json in response breaking the module response handling. See https://github.com/grafana/grafana/issues/77673 --- plugins/modules/grafana_folder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/modules/grafana_folder.py b/plugins/modules/grafana_folder.py index d39e56e4..380a510c 100644 --- a/plugins/modules/grafana_folder.py +++ b/plugins/modules/grafana_folder.py @@ -215,7 +215,10 @@ def _send_request(self, url, data=None, headers=None, method="GET"): error_msg = resp.read()['message'] self._module.fail_json(failed=True, msg=error_msg) elif status_code == 200: - return self._module.from_json(resp.read()) + # XXX: Grafana folders endpoint stopped sending back json in response for delete operations + # see https://github.com/grafana/grafana/issues/77673 + response = resp.read() or "{}" + return self._module.from_json(response) self._module.fail_json(failed=True, msg="Grafana Folders API answered with HTTP %d" % status_code) def get_version(self):