changeset 8256:3a04ff6f1004

fix: crash when logging ip if roundup-server times out Under some conditions (seen in production, no reproducer), if connection timed out, there is no headers attribute RoundupRequestHandler. Check for headers attr before accessing self.headers.
author John Rouillard <rouilj@ieee.org>
date Wed, 01 Jan 2025 17:51:05 -0500
parents 7d72b9a9fe9c
children 3630246c5c36
files roundup/scripts/roundup_server.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/scripts/roundup_server.py	Wed Jan 01 15:48:01 2025 -0500
+++ b/roundup/scripts/roundup_server.py	Wed Jan 01 17:51:05 2025 -0500
@@ -542,7 +542,9 @@
         """
         from_forwarded_header=""
         forwarded_for = None
-        if 'X-FORWARDED-FOR' in self.headers:
+
+        # if connection timed out, there is no headers property
+        if hasattr(self, 'headers') and ('X-FORWARDED-FOR' in self.headers):
             forwarded_for = re.split(r'[,\s]',
                                      self.headers['X-FORWARDED-FOR'],
                                      maxsplit=1)[0]

Roundup Issue Tracker: http://roundup-tracker.org/