summaryrefslogtreecommitdiff
path: root/zuul/web
diff options
context:
space:
mode:
authorFelix Edel <felix.edel@bmw.de>2022-02-23 08:25:54 +0100
committerFelix Edel <felix.edel@bmw.de>2022-02-23 08:25:54 +0100
commit8b7535b7a0c12d69e79632e2b1f1a6aad5a9196d (patch)
treeea0802c4683af280bef265c4ba5f2417d70c7901 /zuul/web
parentd5385d7fc58f98d719ebe981e053ff12e639aed6 (diff)
downloadzuul-8b7535b7a0c12d69e79632e2b1f1a6aad5a9196d.tar.gz
Don't fail on missing change_queues key in status json
Since the pipeline state is stored in ZooKeeper, there could be cases where the change_queues key is missing in the status json. This makes API requests fail: 2022-02-22 17:56:18,390 ERROR cherrypy.error.139989033522128: [22/Feb/2022:17:56:18] HTTP Traceback (most recent call last): File "/opt/zuul/lib/python3.8/site-packages/cherrypy/_cprequest.py", line 638, in respond self._do_respond(path_info) File "/opt/zuul/lib/python3.8/site-packages/cherrypy/_cprequest.py", line 697, in _do_respond response.body = self.handler() File "/opt/zuul/lib/python3.8/site-packages/cherrypy/lib/encoding.py", line 223, in __call__ self.body = self.oldhandler(*args, **kwargs) File "/opt/zuul/lib/python3.8/site-packages/cherrypy/lib/jsontools.py", line 59, in json_handler value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) File "/opt/zuul/lib/python3.8/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__ return self.callable(*self.args, **self.kwargs) File "/opt/zuul/lib/python3.8/site-packages/zuul/web/__init__.py", line 1050, in status_change return result_filter.filterPayload(payload) File "/opt/zuul/lib/python3.8/site-packages/zuul/web/__init__.py", line 193, in filterPayload for change_queue in pipeline['change_queues']: KeyError: 'change_queues' Fix this by using a .get() call rather than directly accessing the dictionary key by name. A similar issue was already fixed in [1]. [1]: https://review.opendev.org/c/zuul/zuul/+/829018 Change-Id: I947f58f02c3da7dad35d1fc186c7026800f7cbdd
Diffstat (limited to 'zuul/web')
-rwxr-xr-xzuul/web/__init__.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index a3f7dcbcc..b92ccabea 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -207,7 +207,7 @@ class ChangeFilter(object):
def filterPayload(self, payload):
status = []
for pipeline in payload['pipelines']:
- for change_queue in pipeline['change_queues']:
+ for change_queue in pipeline.get('change_queues', []):
for head in change_queue['heads']:
for change in head:
if self.wantChange(change):