Skip to content

Commit 2f0ddfe

Browse files
ohmayrparthea
andauthored
fix: disable logging response body for async logs (#1756)
* fix: disable logging response body for async logs * remove unused test code --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 92f60d6 commit 2f0ddfe

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

google/auth/aio/_helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,10 @@ async def response_log_async(logger: logging.Logger, response: Any) -> None:
5353
response: The HTTP response object to log.
5454
"""
5555
if _helpers.is_logging_enabled(logger):
56-
json_response = await _parse_response_async(response)
56+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1755):
57+
# Parsing the response for async streaming logging results in
58+
# the stream to be empty downstream. For now, we will not be logging
59+
# the response for async responses until we investigate further.
60+
# json_response = await _parse_response_async(response)
61+
json_response = None
5762
_helpers._response_log_base(logger, json_response)

tests/aio/test__helpers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,13 @@ async def test_response_log_debug_disabled(logger, caplog, base_logger):
6565

6666
@pytest.mark.asyncio
6767
async def test_response_log_debug_enabled_response_json(logger, caplog, base_logger):
68-
class MockResponse:
69-
async def json(self):
70-
return {"key1": "value1", "key2": "value2", "key3": "value3"}
71-
72-
response = MockResponse()
68+
response = None
7369
caplog.set_level(logging.DEBUG, logger=_MOCK_CHILD_LOGGER_NAME)
7470
await _helpers.response_log_async(logger, response)
7571
assert len(caplog.records) == 1
7672
record = caplog.records[0]
7773
assert record.message == "Response received..."
78-
assert record.httpResponse == {"key1": "value1", "key2": "value2", "key3": "value3"}
74+
assert record.httpResponse == "<class 'NoneType'>"
7975

8076

8177
@pytest.mark.asyncio

0 commit comments

Comments
 (0)