diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 020e01c..4c2e2e1 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -48,6 +48,7 @@ class APIERROR(enum.Enum): ENOTASSIGNEE = 'Only the assignee can merge this review' ENOTASSIGNED = 'This request must be assigned to be merged' ENOUSER = 'No such user found' + ENOCOMMENT = 'Comment not found' def check_api_acls(acls, optional=False): diff --git a/pagure/api/issue.py b/pagure/api/issue.py index 4c63659..32eba50 100644 --- a/pagure/api/issue.py +++ b/pagure/api/issue.py @@ -444,6 +444,9 @@ def api_view_issue_comment(repo, issueid, commentid, username=None): 403, error_code=APIERROR.EISSUENOTALLOWED) comment = pagure.lib.get_issue_comment(SESSION, issue.uid, commentid) + if not comment: + raise pagure.exceptions.APIError( + 404, error_code=APIERROR.ENOCOMMENT) output = comment.to_json(public=True) output['avatar_url'] = pagure.lib.avatar_url(comment.user.user, size=16)