From d8af82c4d533d11a74a362601b9a14f51d1cab9e Mon Sep 17 00:00:00 2001 From: Nick Maludy Date: Tue, 25 Jun 2019 14:42:13 -0400 Subject: [PATCH 1/2] Set content-length to 0 in logging messages when returnvalue is a Generator or Chain --- st2common/st2common/middleware/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st2common/st2common/middleware/logging.py b/st2common/st2common/middleware/logging.py index 66c32187c7..fa984a60b6 100644 --- a/st2common/st2common/middleware/logging.py +++ b/st2common/st2common/middleware/logging.py @@ -99,7 +99,7 @@ def custom_start_response(status, headers, exc_info=None): if isinstance(retval, (types.GeneratorType, itertools.chain)): # Note: We don't log the result when return value is a generator, because this would # result in calling str() on the generator and as such, exhausting it - content_length = [float('inf')] + content_length = [0] log_result = False # Log the response From 6d709b50f9dbea5a0376b9aff7cc1cac39c1ab73 Mon Sep 17 00:00:00 2001 From: Nick Maludy Date: Tue, 25 Jun 2019 14:53:43 -0400 Subject: [PATCH 2/2] Added changelog message for content_length update --- CHANGELOG.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ec63ecc90e..b064367033 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,12 @@ Fixed * Allow tasks defined in the same task transition with ``fail`` to run for orquesta. (bug fix) * Fix workflow service to handle unexpected coordinator and database errors. (bug fix) #4704 #4705 * Fix filter ``to_yaml_string`` to handle mongoengine base types for dict and list. (bug fix) #4700 +* Fixed logging middleware to output a ``content_length`` of ``0`` instead of ``Infinity`` + when the type of data being returned is not supported. Previously, when the value was + set to ``Infinity`` this would result in invalid JSON being output into structured + logs. (bug fix) #4722 + + Contributed by Nick Maludy (@nmaludy Encore Technologies) 3.0.1 - May 24, 2019 --------------------