Skip to content

Conversation

@germanop
Copy link

@germanop germanop commented Sep 13, 2024

If GET fails, the body is empty, so an attempt to convert the body to JSON raises an exception.

The solution here is to return a valid empty JSON body to the caller, that might expect a valid JSON.

This problem has been tackled in other places (but not in set_user_role nor set_grafana_put) in different ways.

  • get_grafana_version does not attempt anything if status is not 200
  • log_response catches ValueError exceptions and then logs r.text (fine, because print can handle None)
  • set_grafana_post catches ValueError and then returns r.text.

I did not go for the same approach as set_grafana_post because I believe the caller should always receive a valid JSON.

When a GET fails the body is empty, so a following attempt to
convert the body to json fails.
Now, if GET fails we return an empty json, given the caller may expect
a valid json.
@mt3593 mt3593 mentioned this pull request Dec 17, 2024
@mt3593
Copy link
Contributor

mt3593 commented Dec 17, 2024

@abalalaev or anyone else, any chance of getting this merged?

@mt3593
Copy link
Contributor

mt3593 commented Dec 17, 2024

Also #279 appears to fix the same bug linked to issue #277

@germanop
Copy link
Author

germanop commented Jun 5, 2025

Hi, any updates on this?

@Siradjedd
Copy link

any updates on this?

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

Successfully merging this pull request may close these issues.

3 participants