From 790d38b6468ee5d97fb24a659e62e4b0fcd45efb Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 9 Aug 2023 15:17:55 -0700 Subject: [PATCH] Handled Google Directory API bug in `gam print groups` that caused a trap. --- docs/GamUpdates.md | 4 ++++ src/GamUpdate.txt | 4 ++++ src/gam/__init__.py | 15 ++++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index b925a2e7..d0e9f427 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,6 +10,10 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation. +### 6.62.03 + +Handled Google Directory API bug in `gam print groups` that caused a trap. + ### 6.62.02 Fixed bug introduced in 6.62.01 that caused a trap that broke `redirect csv ... multiprocess`. diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 0f7d3e53..8ef850f2 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,10 @@ Merged GAM-Team version +6.62.03 + +Handled Google Directory API bug in `gam print groups` that caused a trap. + 6.62.02 Fixed bug introduced in 6.62.01 that caused a trap that broke `redirect csv ... multiprocess`. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 3b217143..a7eb6858 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -2375,8 +2375,11 @@ def invalidQuery(query): def invalidMember(kwargs): if 'userKey' in kwargs: badRequestWarning(Ent.GROUP, Ent.MEMBER, kwargs['userKey']) - else: + return True + if 'query' in kwargs: badRequestWarning(Ent.GROUP, Ent.QUERY, invalidQuery(kwargs['query'])) + return True + return False def invalidUserSchema(schema): if isinstance(schema, list): @@ -30821,8 +30824,9 @@ def doPrintGroups(): pageMessage=getPageMessage(showFirstLastItems=True), messageAttribute='email', throwReasons=GAPI.GROUP_LIST_USERKEY_THROW_REASONS, orderBy='email', fields=cdfieldsnp, maxResults=maxResults, **kwargs) - except (GAPI.invalidMember, GAPI.invalidInput): - invalidMember(kwargs) + except (GAPI.invalidMember, GAPI.invalidInput) as e: + if not invalidMember(kwargs): + entityActionFailedExit([Ent.GROUP, None], str(e)) entityList = [] except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.forbidden, GAPI.badRequest): if kwargs.get('domain'): @@ -31052,8 +31056,9 @@ def getGroupMembersEntityList(cd, entityList, matchPatterns, fieldsList, kwargs) pageMessage=getPageMessage(showFirstLastItems=True), messageAttribute='email', throwReasons=GAPI.GROUP_LIST_USERKEY_THROW_REASONS, orderBy='email', fields=f'nextPageToken,groups({",".join(set(fieldsList))})', **kwargs) - except (GAPI.invalidMember, GAPI.invalidInput): - invalidMember(kwargs) + except (GAPI.invalidMember, GAPI.invalidInput) as e: + if not invalidMember(kwargs): + entityActionFailedExit([Ent.GROUP, None], str(e)) entityList = [] except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.forbidden, GAPI.badRequest): if kwargs.get('domain'):