Reliable error/return code detection with GAM commands

41 views
Skip to first unread message

Jesse Weiman

unread,
Apr 14, 2026, 6:34:39 PM (8 days ago) Apr 14
to GAM for Google Workspace
Hello all,

I am working on scripts and automations which make use of the GAM tool by calling the binary in a subprocess and reading its output.

For "gam csv ..." commands, this can be awkward, since individual commands (or all of them) run by CSV processing may fail in some manner, but if the overall process runs fine, it will return with a success code. I have taken to searching for the word "failed" in the stderr output as a hack-ish attempt at working around this, but that feels a bit messy. Potential false positives (what is a group being processed has the word "failed" in it. Or the stderr output may change, as i don't believe it's documented or guaranteed anywhere (let me know if I am wrong).

For single commands this becomes simpler, as they will indeed reliably return non-zero on any issues. However, there is still some nuance to be had, as failing to add a user to a google group due to their membership already existing is a very distinct error, compared to the group address being entirely malformed/nonexistant.

Maybe there are clear, documented ways to parse this out reliably, I haven't meticulously tested all the commands I want to run under various conditions and documented their output. But before I do that, was wondering if there is some documentation or advice around this.

Thanks!

Ross Scroggs

unread,
Apr 14, 2026, 7:07:50 PM (8 days ago) Apr 14
to google-ap...@googlegroups.com
Send me a private Meet/Zoom invitation and I'll help.

Ross
----
Ross Scroggs



--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-manager/529029d1-17d1-49be-9218-76b733b8b16dn%40googlegroups.com.

Jesse Weiman

unread,
Apr 17, 2026, 8:19:59 PM (5 days ago) Apr 17
to GAM for Google Workspace
Hi Ross,

Thanks for the quick offer to hop in and help out. In between posting this thread and now, I ended up coming across the "showcmds" argument for GAM, which resolved the issue I was having with parsing out per-command returns in CSV/batch functionality.

However, I still am unsure about documentation/specifics on which return codes (https://github.com/GAM-team/GAM/wiki/GAM-Return-Codes) are expected per-command and what their specific meaning is. Is this something which I would need to cross-reference with the source Google API docs related to the specific command(s)? I believe this is something which would be beneficial to add directly into the GAM wiki, or at the very least include links to the relevant Google API docs beneath each distinct command.

I also do have a completely unrelated question, I guess I could make a new thread for it but: I've been running into some annoying issues regarding the Google API's lack of SLA or Retry-After information, for API actions which have propagation time. I have taken to using exponentially increasing sleep times until the action succeeds (I believe this is what Google docs recommends) as the solution to this, but was just generally curious how the GAM project works around this, eg for unit testing (or if this is something the project specifically avoids even worrying about). Or how other projects deal with it.

Regards

Ross Scroggs

unread,
Apr 20, 2026, 10:10:58 AM (2 days ago) Apr 20
to google-ap...@googlegroups.com
Jesse,

Each GAM wiki page that describes commands has a link at the top: API documentation
that contains one or more links to Goople API docs. Except for a few Classroom APIs,
there is almost no documentation about what errors are returned by the various APIs.

If you see an error message like this:
ERROR: 412: adminCannotUnsuspend - Cannot restore a user suspended for abuse.
it means that GAM does not recognize the error. When these are reported to me,
I add code to GAM to handle the error.

The Google API return erroras like this:

limitExceeded,quotaExceeded,rateLimitExceeded

When these occur, GAM uses the Google recommeded exponential backup process.


Where are you experincing these issues?


Ross

----
Ross Scroggs



Jesse Weiman

unread,
Apr 20, 2026, 11:57:51 AM (2 days ago) Apr 20
to GAM for Google Workspace
Not at all surprised to hear that Google's documentation is completely lacking in detail! Oh well. Guess we're in the same boat then.

My problems with propagation/"Eventual consistency" are related to some semi-automated scripts I'm designing, as well as the testing framework around them. In both cases, users are created, added to groups, and in the case of testing deleting, all in rapid succession. If these actions are strung together quickly enough, as would happen in a script, as opposed to hand-typing in the terminal, Google starts throwing errors. So I have some helper functions for retrying commands as needed until a successful return code is provided. This might be the best practice/recommended solution already, but was curious to check, and if there's any examples in the GAM project of how its handled, eg if the testing framework has to manage similar problems, I wouldnt mind a pointer to where I can reference it in code as a comparison.

Ross Scroggs

unread,
Apr 20, 2026, 12:15:03 PM (2 days ago) Apr 20
to google-ap...@googlegroups.com
Jesse,

If you have a moment send me a prinvate Meet/Zoom invitation and we'll discuss.
]
There is no universal wait for waiting for success, there are some specific cases, for instance there is:


Ross
----
Ross Scroggs


Reply all
Reply to author
Forward
0 new messages