#2308 hub: return empty list in get_notification_recipients()
Merged 2 years ago by tkopecek. Opened 2 years ago by ktdreyer.
ktdreyer/koji build-notifications  into  master

file modified
+1 -1
@@ -8377,7 +8377,7 @@ 

          #   using all package owners from all tags would be way overkill.


      if not recipients:

-         return None

+         return []


      # apply the out outs

      user_ids = list(set([r['user_id'] for r in recipients]))

If we find no recipients, return an empty list, rather than None.

This fixes a crash in build_notifications() where we expect to call len() on the return value from get_notification_recipients().

Fixes: https://pagure.io/koji/issue/2307

I think PR #2309 is sufficient

It might resolve the issue at hand, but it seems more correct to return an empty list here. The def get_notification_recipients normally returns a list, and there is no clear meaning to returning None here.

The stanza where we were returning None is simple a slight optimization that skips the rest of the logic when the query is empty. If the function were to instead continue here, it would filter that empty list to another empty list and return it.

that makes sense


Commit eb8d7f9 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

2 years ago