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 authored and ptoscano committed Jan 2, 2024
1 parent 3eb3cb1 commit 52e95f8
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 52e95f8

Please sign in to comment.