From f0ef1582ae592b4aea023b8b4931703568a5f72d Mon Sep 17 00:00:00 2001 From: Avery Date: Fri, 22 Nov 2024 11:06:21 -0800 Subject: [PATCH] Do not throw errors when trying to list members from a non-existent Google Group (#5522) * Do not throw errors when trying to list members from a non-existent Google Group * Update src/dispatch/plugins/dispatch_google/groups/plugin.py Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Signed-off-by: Avery --------- Signed-off-by: Avery Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> --- src/dispatch/plugins/dispatch_google/groups/plugin.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dispatch/plugins/dispatch_google/groups/plugin.py b/src/dispatch/plugins/dispatch_google/groups/plugin.py index 2d42c51d4ce3..ba53c3b20bf3 100644 --- a/src/dispatch/plugins/dispatch_google/groups/plugin.py +++ b/src/dispatch/plugins/dispatch_google/groups/plugin.py @@ -170,11 +170,16 @@ def remove(self, email: str, participants: List[str]): for p in participants: remove_member(client, email, p) - def list(self, email: str): + def list(self, email: str) -> list[str]: """Lists members from an existing Google Group.""" client = get_service(self.configuration, "admin", "directory_v1", self.scopes) - members = list_members(client, email) - return [m["email"] for m in members.get("members", [])] + try: + members = list_members(client, email) + return [m["email"] for m in members.get("members", [])] + except HttpError as e: + if e.resp.status == 404: + log.warning(f"Group does not exist. GroupKey={email} Trying to list members.") + return [] def delete(self, email: str): """Deletes an existing Google group."""