Created
May 27, 2026 15:23
-
-
Save meshin/bdf204b585aae775327cd9f4dce05dd3 to your computer and use it in GitHub Desktop.
Deactivate Gmail integrations with unrecoverable watch errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Deactivate Gmail integrations that failed watch renewal due to unrecoverable errors: | |
| # - failedPrecondition: Mail service not enabled | |
| # - PERMISSION_DENIED: Request had insufficient authentication scopes | |
| # | |
| # Set dry_run = false below to execute | |
| dry_run = true | |
| BROKEN_IDS = [ | |
| 81530, # failedPrecondition: Mail service not enabled | |
| 98276, # PERMISSION_DENIED: insufficient authentication scopes | |
| ].freeze | |
| ActsAsTenant.without_tenant do | |
| integrations = Integration.where(id: BROKEN_IDS) | |
| integrations.each do |integration| | |
| print "Integration #{integration.id} (account #{integration.account_id}): " | |
| if dry_run | |
| puts "would deactivate (currently #{integration.deactivated_at? ? 'already deactivated' : 'active'})" | |
| next | |
| end | |
| if integration.deactivated_at? | |
| puts 'already deactivated — skip' | |
| next | |
| end | |
| integration.update!(deactivated_at: Time.current) | |
| puts "deactivated" | |
| end | |
| end | |
| puts "(dry run — set dry_run = false to execute)" if dry_run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment