Skip to content

Commit

Permalink
Fix an error in debug logging of cloud-what
Browse files Browse the repository at this point in the history
The `requests.PreparedRequest` may not have any `.body` attribute set.
This happens when unit tests are run, for example. In that case the test
would crash.
  • Loading branch information
m-horky committed Dec 19, 2023
1 parent 51f75db commit 6ec0759
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cloud_what/_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _debug_print_http_request(request: requests.PreparedRequest) -> None:
print(colorize("Request headers:", COLOR.GREEN))
print(colorize(f"{request.headers}", COLOR.BLUE))

if os.environ.get("SUBMAN_DEBUG_PRINT_REQUEST_BODY", "") and request.body is not None:
if os.environ.get("SUBMAN_DEBUG_PRINT_REQUEST_BODY", "") and hasattr(request, "body"):
print(colorize("Request body:", COLOR.GREEN))
print(colorize(f"{request.body}", COLOR.YELLOW))

Expand Down

0 comments on commit 6ec0759

Please sign in to comment.