mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
The Google API will often return a missing `members` key alongside a `200` response from their members API. The documentation here isn't clear whether this key is expected or not, but since the sync has been working fine up until #8608, we can only surmise that the missing key in fact means the group has no members. This PR updates the Google API client so that a `default_if_missing` can be passed in which is returned if the API response is missing the JSON key to fetch. For the users, groups, and organization units fetches, we consider a missing key to be an error and we return `{:error, :invalid_response}` since this most likely indicates an API problem. For the members endpoint, we consider the missing key to be the empty set. Additionally, a bug is fixed that was introduced in #8608 whereupon we returned `{:error, :retry_later}` for newly-accounted-for API responses, which would have caused a "sync failed" email to be sent to the admins on the instance. Instead, we want to return `{:error, :invalid_response}` which will stop the sync from progressing, and log it internally.