[github2fedmsg] Fix for KeyError

Should fix the issue in https://pagure.io/fedora-infrastructure/issue/11776

Signed-off-by: Michal Konecny <mkonecny@redhat.com>
This commit is contained in:
Michal Konecny 2024-02-20 12:28:05 +01:00 committed by zlopez
parent 26358b62a2
commit 3dc3ca88ae
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,26 @@
diff --git a/github2fedmsg/views/webhooks.py b/github2fedmsg/views/webhooks.py
index be6b707..0637143 100644
--- a/github2fedmsg/views/webhooks.py
+++ b/github2fedmsg/views/webhooks.py
@@ -167,10 +167,19 @@ def build_fas_lookup(payload):
usernames = set()
# Trawl through every possible corner we can to find github usernames
+ # Fix for https://pagure.io/fedora-infrastructure/issue/11776
if 'commits' in payload:
for commit in payload['commits']:
- usernames.add(commit['committer']['username'])
- usernames.add(commit['author']['username'])
+ if 'committer' in commit:
+ if 'username' in commit['committer']:
+ usernames.add(commit['committer']['username'])
+ elif 'name' in commit['committer']:
+ usernames.add(commit['committer']['name'])
+ if 'author' in commit:
+ if 'username' in commit['author']:
+ usernames.add(commit['author']['username'])
+ elif 'name' in commit['author']:
+ usernames.add(commit['author']['name'])
if 'pusher' in payload:
usernames.add(payload['pusher']['name'])

View file

@ -67,6 +67,17 @@
notify:
- restart apache
# Fix for https://pagure.io/fedora-infrastructure/issue/11776
- name: hotfix - Fix the KeyError when looking for user in github event
ansible.posix.patch:
src: 11776.patch
dest: /usr/lib/python2.7/site-packages/github2fedmsg/views/webhooks.py
tags:
- hotfix
- github2fedmsg
notify:
- restart apache
- name: ensure selinux lets httpd talk to postgres
seboolean: name=httpd_can_network_connect_db persistent=yes state=yes
tags: