Skip to content

: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.

fix(github): classify exhausted rate limits as retryable, not tracked errors (#80419)

Tom Owers2da3953280d1
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py
index cdc3c0a4f3bd..a9d23c53dc52 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py
@@ -299,6 +299,12 @@ If automatic creation failed, your token needs webhook permissions — the **adm
"Missing integration ID": "Integration ID is not configured. Please reconnect your GitHub account.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # A GitHubRateLimitError that survives _fetch_page's own rate-limit-aware tenacity retry
+ # still gets picked up by Temporal's activity retry; classify it as retryable so it's
+ # logged as a warning rather than tracked as an exception. Mirrors Stripe's equivalent case.
+ return {"GitHub API rate limit exceeded"}
+
def get_oauth_accounts(
self, integration_id: int, team_id: int, search: str | None = None
) -> list[IntegrationAccount]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py
index c4f4ca76dea3..9053e758e54b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py
@@ -120,6 +120,15 @@ class TestGithubSource:
def test_non_retryable_errors(self, expected_key):
assert expected_key in self.source.get_non_retryable_errors()
+ def test_rate_limit_error_is_retryable_not_non_retryable(self):
+ # A GitHubRateLimitError that exhausts _fetch_page's tenacity retry must stay retryable
+ # so it never gets classified as a permanent failure that disables the source.
+ observed_error = "GitHub API rate limit exceeded (resets at 1786360951)"
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert not any(key in observed_error for key in non_retryable_errors)
+ retryable_errors = self.source.get_retryable_errors()
+ assert error_message_matches(observed_error, retryable_errors)
+
@pytest.mark.parametrize(
"raised_message,expected_key",
[