From 4781e088a38bf5d0e986fd763d0e1e6b11325f2a Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Wed, 12 Jun 2024 12:09:58 +0200 Subject: [PATCH] fix: rethrow JSONDecodeError after printing the undecodable value as a warning --- nyacme/handlers/cloudflare.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nyacme/handlers/cloudflare.py b/nyacme/handlers/cloudflare.py index 0f0fd18..ff57024 100644 --- a/nyacme/handlers/cloudflare.py +++ b/nyacme/handlers/cloudflare.py @@ -23,7 +23,11 @@ class CloudflareHandler(Handler): env = os.environ.copy() env['CF_API_TOKEN'] = self.secret res = subprocess.run(['flarectl', '--json'] + args, check=True, stdout=subprocess.PIPE, env=env) - return json.loads(res.stdout) + try: + return json.loads(res.stdout) + except json.decoder.JSONDecodeError as ex: + self.log.warning('could not decode as JSON: %s', res.stdout) + raise ex def create(self, record_name: str, record_value: str) -> None: full_record_name = record_name + '.' + self.zone