:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(github): treat suspended App installation as non-retryable (#64630)
Tom Owers57c4bd522da7
diff --git a/posthog/temporal/data_imports/sources/github/source.py b/posthog/temporal/data_imports/sources/github/source.pyindex 33f10c0a226e..af80807a54d5 100644--- a/posthog/temporal/data_imports/sources/github/source.py+++ b/posthog/temporal/data_imports/sources/github/source.py@@ -118,6 +118,11 @@ class GithubSource(ResumableSource[GithubSourceConfig, GithubResumeConfig], OAut# "Failed to refresh installation token" prefix would also swallow transient 5xx/429# refresh failures, which must stay retryable.'Failed to refresh installation token: {"message":"Not Found"': "Your GitHub App installation could not be found. It may have been uninstalled or had its access revoked. Please reconnect your GitHub account.",+ # GitHub suspends an App installation (org owner action, or GitHub itself) and returns+ # a 403 "This installation has been suspended" when minting a token. The custom+ # GitHubIntegrationError message isn't a requests "403 Client Error" string, so it+ # falls through the status-text keys above. Retrying can't unsuspend it.+ "This installation has been suspended": "Your GitHub App installation has been suspended. Re-enable it from your GitHub organization's installed GitHub Apps settings, then reconnect your GitHub account.",# Deterministic credential/config errors from _get_access_token and OAuthMixin.# These never resolve on retry — the source needs reconfiguring or reconnecting."Missing GitHub integration ID": "No GitHub account is connected. Please reconnect your GitHub account.",diff --git a/posthog/temporal/data_imports/sources/github/tests/test_github_source_class.py b/posthog/temporal/data_imports/sources/github/tests/test_github_source_class.pyindex 33d7321db42f..8321839dff21 100644--- a/posthog/temporal/data_imports/sources/github/tests/test_github_source_class.py+++ b/posthog/temporal/data_imports/sources/github/tests/test_github_source_class.py@@ -27,11 +27,23 @@ class TestGithubSource:"GitHub access token not found","Integration not found","Missing integration ID",+ "This installation has been suspended",],)def test_non_retryable_errors(self, expected_key):assert expected_key in self.source.get_non_retryable_errors()+ def test_suspended_installation_token_refresh_is_non_retryable(self):+ # The raw GitHubIntegrationError raised by refresh_access_token on a suspended installation.+ error_message = (+ 'Failed to refresh installation token: {"message":"This installation has been suspended",'+ '"documentation_url":"https://docs.github.com/rest/reference/apps#create-an-installation-access-token-for-an-app",'+ '"status":"403"}'+ )+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert "This installation has been suspended" in non_retryable_errors+ assert "This installation has been suspended" in error_message+@pytest.mark.parametrize("selection,github_integration_id,personal_access_token,expected_error",[