: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(google_sheets): stop tracking transient 5xx/429 Sheets API errors as exceptions (#73812)
Tom Owers3af085d135fc
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/source.pyindex 020a7c826a3d..85d915a119e4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/source.py@@ -75,6 +75,21 @@ class GoogleSheetsSource(SimpleSource[GoogleSheetsSourceConfig]):"Requested entity was not found": "Import failed: the Google Sheet or worksheet could not be found. It may have been deleted or moved, or is no longer shared with our service account. Please check the spreadsheet URL and its sharing settings.",}+ def get_retryable_errors(self) -> set[str]:+ # `_retry_on_transient_api_error` already retries these Sheets API responses in-process+ # (see `_RETRYABLE_API_ERROR_CODES` in google_sheets.py) before re-raising once its attempt+ # budget is exhausted. gspread's `APIError.__str__` embeds the HTTP status as a stable+ # "[<code>]" substring — match on that rather than the message text, which Google can+ # reword. Temporal then retries the whole activity, so the failure is transient and+ # self-recovering.+ return {+ "APIError: [429]",+ "APIError: [500]",+ "APIError: [502]",+ "APIError: [503]",+ "APIError: [504]",+ }+def get_schemas(self,config: GoogleSheetsSourceConfig,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.pyindex a90ad971bbad..978523c590a9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.py@@ -456,6 +456,18 @@ def test_error_string_matches_a_non_retryable_key(error):assert any(key in str(error) for key in non_retryable_errors)[email protected]("status_code", [429, 500, 502, 503, 504])+def test_error_string_matches_a_retryable_key(status_code):+ """`_retry_on_transient_api_error` already retries these status codes in-process before+ re-raising; the framework then logs at `warning` instead of `exception` only if the re-raised+ error matches one of `get_retryable_errors()`'s keys. If a code drops out of this set, the+ transient error starts polluting error tracking again even though Temporal still retries it."""+ error = _api_error(status_code, "The service is currently unavailable.")+ retryable_errors = GoogleSheetsSource().get_retryable_errors()++ assert any(key in str(error) for key in retryable_errors)++@pytest.mark.parametrize("call_site",[