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 fdd5e6e commit aca73d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/294-bump-grafana-version.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
minor_changes:
- Bump version of Python used in tests to 3.10
bugfixes:
- grafana_folder, fix an issue during delete (starting Grafana 9.3)
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 aca73d9

Please sign in to comment.