Repository: mozilla/bugbug

Issue:
AttributeError: 'IndexError' object has no attribute 'tb_frame' in Pulse Listener
```
Jul 29 09:37:20 bugbug app/web.1: Traceback (most recent call last): 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/bugbug_http/listener.py", line 69, in _on_message 
Jul 29 09:37:20 bugbug app/web.1:     user = body["payload"]["data"]["pushlog_pushes"][0]["user"] 
Jul 29 09:37:20 bugbug app/web.1: IndexError: list index out of range 
Jul 29 09:37:20 bugbug app/web.1: During handling of the above exception, another exception occurred: 
Jul 29 09:37:20 bugbug app/web.1: Traceback (most recent call last): 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/bin/bugbug-http-pulse-listener", line 8, in <module> 
Jul 29 09:37:20 bugbug app/web.1:     sys.exit(main()) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/bugbug_http/listener.py", line 94, in main 
Jul 29 09:37:20 bugbug app/web.1:     consumer.run() 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/mixins.py", line 175, in run 
Jul 29 09:37:20 bugbug app/web.1:     for _ in self.consume(limit=None, **kwargs): 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/mixins.py", line 197, in consume 
Jul 29 09:37:20 bugbug app/web.1:     conn.drain_events(timeout=safety_interval) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/connection.py", line 324, in drain_events 
Jul 29 09:37:20 bugbug app/web.1:     return self.transport.drain_events(self.connection, **kwargs) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/transport/pyamqp.py", line 103, in drain_events 
Jul 29 09:37:20 bugbug app/web.1:     return connection.drain_events(**kwargs) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/amqp/connection.py", line 508, in drain_events 
Jul 29 09:37:20 bugbug app/web.1:     while not self.blocking_read(timeout): 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/amqp/connection.py", line 514, in blocking_read 
Jul 29 09:37:20 bugbug app/web.1:     return self.on_inbound_frame(frame) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/amqp/method_framing.py", line 79, in on_frame 
Jul 29 09:37:20 bugbug app/web.1:     callback(channel, msg.frame_method, msg.frame_args, msg) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/amqp/connection.py", line 520, in on_inbound_method 
Jul 29 09:37:20 bugbug app/web.1:     return self.channels[channel_id].dispatch_method( 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/amqp/abstract_channel.py", line 145, in dispatch_method 
Jul 29 09:37:20 bugbug app/web.1:     listener(*args) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/amqp/channel.py", line 1615, in _on_basic_deliver 
Jul 29 09:37:20 bugbug app/web.1:     fun(msg) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/messaging.py", line 624, in _receive_callback 
Jul 29 09:37:20 bugbug app/web.1:     return on_m(message) if on_m else self.receive(decoded, message) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/messaging.py", line 590, in receive 
Jul 29 09:37:20 bugbug app/web.1:     [callback(body, message) for callback in callbacks] 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/kombu/messaging.py", line 590, in <listcomp> 
Jul 29 09:37:20 bugbug app/web.1:     [callback(body, message) for callback in callbacks] 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/site-packages/bugbug_http/listener.py", line 82, in _on_message 
Jul 29 09:37:20 bugbug app/web.1:     traceback.print_tb(e) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/traceback.py", line 53, in print_tb 
Jul 29 09:37:20 bugbug app/web.1:     print_list(extract_tb(tb, limit=limit), file=file) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/traceback.py", line 72, in extract_tb 
Jul 29 09:37:20 bugbug app/web.1:     return StackSummary.extract(walk_tb(tb), limit=limit) 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/traceback.py", line 347, in extract 
Jul 29 09:37:20 bugbug app/web.1:     for f, lineno in frame_gen: 
Jul 29 09:37:20 bugbug app/web.1:   File "/usr/local/lib/python3.8/traceback.py", line 312, in walk_tb 
Jul 29 09:37:20 bugbug app/web.1:     yield tb.tb_frame, tb.tb_lineno 
Jul 29 09:37:20 bugbug app/web.1: AttributeError: 'IndexError' object has no attribute 'tb_frame' 
```

The pulse listener is killed and no longer listens for pushes.


Discussion:

Resolving patch:
diff --git a/http_service/bugbug_http/listener.py b/http_service/bugbug_http/listener.py
--- a/http_service/bugbug_http/listener.py
+++ b/http_service/bugbug_http/listener.py
@@ -83,8 +83,8 @@ def _on_message(body, message):
                 logger.warning(
                     "We got status: {} for: {}".format(response.status_code, url)
                 )
-    except Exception as e:
-        traceback.print_tb(e)
+    except Exception:
+        traceback.print_exc()
     finally:
         message.ack()
 


Test patch: