diff --git a/CHANGELOG.md b/CHANGELOG.md index b4d8f55..77712b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ ### Fixed +* Add compatibility with [requests](https://requests.readthedocs.io) + version 2.25 and higher. + ### Misc * Improve test coverage by running an HTTP server to fake the Patroni API (#55 diff --git a/check_patroni/types.py b/check_patroni/types.py index 096f31b..e3c143d 100644 --- a/check_patroni/types.py +++ b/check_patroni/types.py @@ -1,4 +1,5 @@ from typing import Any, Callable, List, Optional, Tuple, Union +import json from urllib.parse import urlparse import attr @@ -71,7 +72,7 @@ def rest_api(self, service: str) -> Any: try: return r.json() - except requests.exceptions.JSONDecodeError: + except (json.JSONDecodeError, ValueError): return None raise nagiosplugin.CheckError("Connection failed for all provided endpoints")