From bbaf967f17edb09059c4b445f4259eb64bea76d1 Mon Sep 17 00:00:00 2001 From: Antonio Yuen Date: Thu, 12 Feb 2026 18:58:16 -0500 Subject: [PATCH 1/2] feat: handle head response --- pyiceberg/catalog/rest/response.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyiceberg/catalog/rest/response.py b/pyiceberg/catalog/rest/response.py index 157e4bfa16..6dcb1bde27 100644 --- a/pyiceberg/catalog/rest/response.py +++ b/pyiceberg/catalog/rest/response.py @@ -98,6 +98,11 @@ def _handle_non_200_response(exc: HTTPError, error_handler: dict[int, type[Excep if uri := error.error_uri: response += f" ({uri})" else: + # Handle empty response bodies (Specifically HEAD requests via exist requests) + if not exc.response.text: + response = f"{exception.__name__}: {exc.response.reason}" + raise exception(response) from exc + error = ErrorResponse.model_validate_json(exc.response.text).error response = f"{error.type}: {error.message}" except JSONDecodeError: From 7612d8a8b303a2c16118d9aff2d18643492804da Mon Sep 17 00:00:00 2001 From: Antonio Yuen Date: Thu, 12 Feb 2026 18:59:44 -0500 Subject: [PATCH 2/2] follow style from neighboring code --- pyiceberg/catalog/rest/response.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyiceberg/catalog/rest/response.py b/pyiceberg/catalog/rest/response.py index 6dcb1bde27..8ebfa823ad 100644 --- a/pyiceberg/catalog/rest/response.py +++ b/pyiceberg/catalog/rest/response.py @@ -101,10 +101,9 @@ def _handle_non_200_response(exc: HTTPError, error_handler: dict[int, type[Excep # Handle empty response bodies (Specifically HEAD requests via exist requests) if not exc.response.text: response = f"{exception.__name__}: {exc.response.reason}" - raise exception(response) from exc - - error = ErrorResponse.model_validate_json(exc.response.text).error - response = f"{error.type}: {error.message}" + else: + error = ErrorResponse.model_validate_json(exc.response.text).error + response = f"{error.type}: {error.message}" except JSONDecodeError: # In the case we don't have a proper response response = f"RESTError {exc.response.status_code}: Could not decode json payload: {exc.response.text}"