Skip to content

Commit

Permalink
[enriched/github2] Fix KeyError 'login'
Browse files Browse the repository at this point in the history
This code fixes when the PR or issue is assigned to an unavailable
user.

Signed-off-by: Quan Zhou <quan@bitergia.com>
  • Loading branch information
zhquan committed Aug 31, 2021
1 parent d98aba7 commit 6480a89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions grimoire_elk/enriched/github2.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
REVIEW_COMMENT_TYPE = 'review_comment'
REPOSITORY_TYPE = 'repository'

USER_NOT_AVAILABLE = {'organizations': []}

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -470,7 +472,7 @@ def __get_rich_pull(self, item):
rich_pr['author_name'] = None

merged_by = pull_request.get('merged_by_data', None)
if merged_by and merged_by is not None:
if merged_by and merged_by != USER_NOT_AVAILABLE:
rich_pr['merge_author_login'] = merged_by['login']
rich_pr['merge_author_name'] = merged_by['name']
rich_pr["merge_author_domain"] = self.get_email_domain(merged_by['email']) if merged_by['email'] else None
Expand Down Expand Up @@ -578,8 +580,7 @@ def __get_rich_issue(self, item):
rich_issue['author_name'] = None

assignee = issue.get('assignee_data', None)
if assignee and assignee is not None:
assignee = issue['assignee_data']
if assignee and assignee != USER_NOT_AVAILABLE:
rich_issue['assignee_login'] = assignee['login']
rich_issue['assignee_name'] = assignee['name']
rich_issue["assignee_domain"] = self.get_email_domain(assignee['email']) if assignee['email'] else None
Expand Down

0 comments on commit 6480a89

Please sign in to comment.