Why doesn't GAM use exit codes on all of its commands for users who use GAM in scheduled tasks?

133 views
Skip to first unread message

Dan Seward

unread,
Dec 6, 2018, 3:32:09 PM12/6/18
to GAM for G Suite
I am a long-time user of gam but at some point in the distant past, the error/exit codes were removed from most of the commands. When calling an executable from a batch file, checking exit codes is a standard process. GAM did a great job handling this until some of the codes were removed. I then had to capture the output and parse it to read the reported error text.


Redirected error output to a file must be done and then parsed to find the error number
Error output included the ERROR: ### for some of the commands but recent versions have changed the error descriptions, making it a long drawn out task to interpret what went wrong inside a program calling GAM.

With every upgrade, I have to save a version of the old program and run every GAM to see 
  1. if an exit code was removed
  2. if the error output changed from any one of the previous versions that was in use for a particular scheduled task
  3. what exit code or text is returned when a command runs successfully - These exit codes are typically 0 but if some one of the errors returns a 0 for any of the possible errors, the standard output must be checked instead.
  4. backend server errors can only be checked when they occur so these can only be checked when the condition exists.
Why can't GAM add back exit codes? To upgrade a single process, I must spend days to check all of the possible errors that can be returned. When the output or errorlevels are the same as the previous version, I can put it into production. When an exit code or error number is not returned on std error, I have to modify the program to search for different text or come up with a different method for trapping the error.

How can this be made a priority?


Example #1: Running a command to add an owner to a group when the user is already an owner. 
The error output was collected from GAM ver 3.65 and compared with GAM ver 4.65

gam update group valid_gr...@email.domain add owner new_...@email.domain 2>error.txt


Error output from Version 3.65
 adding owner new_Owner@email.domain...
ERROR: 409: Member already exists. - duplicate

echo %errorlevel%
0

Error output from Version 4.65
 Group: valid_gr...@email.domain, new_Owner@email.domain Add as OWNER Failed: Duplicate, already a OWNER

C:\Gam365>echo %errorlevel%
C:\Gam365>0

Since the exit code is a 0 even when there are errors, the output must be interpreted. At least on ver 3.65 an Error # is given but on ver 4.65 there are no unique error number to look for. Programers must run the command with specific errors every time there is a new version since there are no consistencies how error text is formatted.


Example #2: Running a command to add an owner to a group when the group does not exist. 
No errorlevel is set and the error # was removed and replaced with the text "Does not exist".

Error output from Version 3.65

 adding owner new_Owner@email.domain...
ERROR: 404: Resource Not Found: groupKey - notFound


C:\Gam365>echo %errorlevel%
C:\Gam365>0


Error output from Version 4.65
Group: invali...@email.domain, Does not exist

C:\Gam365>echo %errorlevel%
C:\Gam365>0



 Example #3: Running different commands with errors returns an error code and others do not. 
No errorlevel is set and the error # was removed and replaced with the text "Does not exist".

Error output from Version 4.65 for 2 different commands

C:\Admin\gamStd465>gam info user invali...@email.domain

ERROR: 404: Resource Not Found: userKey - userNotFound

C:\Admin\gamStd465>echo %errorlevel%
404


Group: invali...@email.domain, Does not exist

C:\gam465>gam user invalid_userid@email.com delegate to valid_delegate@email.com

ERROR: User invalid_userid@email.com: invalid_grant: Invalid email or User ID

C:\gam465>echo %errorlevel%
0

C:\gam465>gam user invalid_delegator@email.com delegate to valid_d...@email.com
Giving Invalid_...@email.com delegate access to valid_d...@email.com (1/1)

ERROR: 404: Invalid delegate - notFound

C:\gam465>echo %errorlevel%
0



Why can't GAM 

Ross Scroggs

unread,
Dec 6, 2018, 5:27:43 PM12/6/18
to google-ap...@googlegroups.com
Dan,

My Advanced GAM (https://github.com/taers232c/GAMADV-XTD) handles output and return codes in a more consistent manner.

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/9c7aa442-2e51-444d-86eb-d7f9800721c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Bri Hatch

unread,
Dec 6, 2018, 7:24:12 PM12/6/18
to google-ap...@googlegroups.com
tl;dr: use advanced gam instead. We've moved to it for that very reason - proper handling of stderr/stdout and accurate exit codes.



On Thu, Dec 6, 2018 at 12:32 PM Dan Seward <sew...@rmu.edu> wrote:
--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/9c7aa442-2e51-444d-86eb-d7f9800721c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Bri Hatch, Systems and Security Engineer. http://www.ifokr.org/bri/

The sooner you fall behind, the more time you'll have to catch up.

Reply all
Reply to author
Forward
0 new messages