From b98fb7fa9ab5be04a4d4a6a11d6215c1e2d72234 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud Date: Mon, 8 Nov 2021 17:25:44 +1100 Subject: [PATCH] Fix issue #4178 Allow retries when the answer is None --- core/dbt/clients/registry.py | 2 ++ core/dbt/utils.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/dbt/clients/registry.py b/core/dbt/clients/registry.py index 2f69bb5dc10..e426bc3c85b 100644 --- a/core/dbt/clients/registry.py +++ b/core/dbt/clients/registry.py @@ -30,6 +30,8 @@ def _get(path, registry_base_url=None): logger.debug('Response from registry: GET {} {}'.format(url, resp.status_code)) resp.raise_for_status() + if resp is None: + raise requests.exceptions.InvalidJSONError('Request error: The response is None', response=resp) return resp.json() diff --git a/core/dbt/utils.py b/core/dbt/utils.py index 9d16aff2e50..448aa0383a8 100644 --- a/core/dbt/utils.py +++ b/core/dbt/utils.py @@ -615,7 +615,7 @@ def _connection_exception_retry(fn, max_attempts: int, attempt: int = 0): """ try: return fn() - except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as exc: + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, requests.exceptions.InvalidJSONError) as exc: if attempt <= max_attempts - 1: logger.debug('Retrying external call. Attempt: ' + f'{attempt} Max attempts: {max_attempts}')