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 a token-mint read timeout as retryable (#108104)

Tom Owers88f76c7e05ac
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 74a6fc264bc0..fe0229d540a8 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
@@ -368,13 +368,14 @@ If automatic creation failed with a permissions error, the fix depends on how yo
# gets the same treatment — a GitHub-side outage, not something reconnecting or reconfiguring
# the source can fix.
#
- # A TLS session cut at the socket while minting the installation access token
- # (``GitHubIntegrationBase.client_request``, called from ``_get_access_token``) has no
- # in-process retry of its own — unlike ``_fetch_page``'s data requests, whose tenacity retry
- # already covers ``requests.ConnectionError`` (the base class ``SSLError`` subclasses).
- # Either way it's a dropped connection, not a GitHub or customer problem, so once Temporal
- # retries the activity the failure is transient and self-recovering. Mirrors ClickHouse's
- # equivalent classification of the same urllib3/OpenSSL wording.
+ # A TLS session cut at the socket, or a read that outran its 10s deadline, while minting the
+ # installation access token (``GitHubIntegrationBase.client_request``, called from
+ # ``_get_access_token``) has no in-process retry of its own — unlike ``_fetch_page``'s data
+ # requests, whose tenacity retry already covers ``requests.ConnectionError`` (the base class
+ # ``SSLError`` subclasses) and ``requests.ReadTimeout`` directly. Either way it's a transient
+ # network blip, not a GitHub or customer problem, so once Temporal retries the activity the
+ # failure is self-recovering. Mirrors ClickHouse's equivalent classification of the same
+ # urllib3/OpenSSL wording.
#
# A GitHubEgressBudgetExhausted gets the same treatment as the GitHub-side rate limit it is
# the twin of. It is our own limiter shedding a deferrable call on purpose, so it is the
@@ -386,6 +387,7 @@ If automatic creation failed with a permissions error, the fix depends on how yo
"Github API error (retryable)",
"UNEXPECTED_EOF_WHILE_READING",
"EOF occurred in violation of protocol",
+ "Read timed out",
}
def get_oauth_accounts(
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 d7abbaa7c88a..7a4aaef7e26f 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
@@ -158,15 +158,21 @@ class TestGithubSource:
retryable_errors = self.source.get_retryable_errors()
assert error_message_matches(observed_error, retryable_errors)
- def test_ssl_eof_error_is_retryable_not_non_retryable(self):
- # A TLS session cut at the socket while minting the installation access token
- # (client_request has no in-process retry, unlike _fetch_page). Must stay retryable so a
- # dropped connection to GitHub doesn't disable the source.
- observed_error = (
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ # A TLS session cut at the socket while minting the installation access token.
"HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: "
"/app/installations/123/access_tokens (Caused by SSLError(SSLEOFError(8, "
- "'[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1032)')))"
- )
+ "'[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1032)')))",
+ # A read timeout on the same call.
+ "HTTPSConnectionPool(host='api.github.com', port=443): Read timed out. (read timeout=10)",
+ ],
+ )
+ def test_token_mint_transport_error_is_retryable_not_non_retryable(self, observed_error):
+ # Neither has an in-process retry (client_request has none, unlike _fetch_page's tenacity
+ # retry). Must stay retryable so a dropped connection or a slow response to GitHub doesn't
+ # disable the source.
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()