Skip to content

Commit

Permalink
fix(folders): make sure to return a json response if Grafana returns …
Browse files Browse the repository at this point in the history
…an empty response

Since Grafana 9.3 the folders endpoint stopped sending back json in response
breaking the module response handling.

See grafana/grafana#77673
  • Loading branch information
rrey committed Nov 4, 2023
1 parent ed9db44 commit a0a0ab9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/modules/grafana_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a0a0ab9

Please sign in to comment.