: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(data-warehouse): mark Google Sheets 404 not found as non-retryable (#61617)
Tom Owersc0274f26b5eb
diff --git a/posthog/temporal/data_imports/sources/google_sheets/source.py b/posthog/temporal/data_imports/sources/google_sheets/source.pyindex 3771607adfbe..31b34ac09cf5 100644--- a/posthog/temporal/data_imports/sources/google_sheets/source.py+++ b/posthog/temporal/data_imports/sources/google_sheets/source.py@@ -39,6 +39,9 @@ class GoogleSheetsSource(SimpleSource[GoogleSheetsSourceConfig]):"SpreadsheetNotFound": None,"must be real number, not str": "Import failed: a numeric column contains a non-numeric value. Ensure every cell in numeric columns is stored as a plain number.","Spreadsheet access denied": "Import failed: PostHog does not have access to this spreadsheet. Please share it with our service account as described at https://posthog.com/docs/cdp/sources/google-sheets",+ # gspread raises APIError "[404]: Requested entity was not found." when the+ # spreadsheet has been deleted or is otherwise unreachable. Retrying cannot recover.+ "Requested entity was not found": "Import failed: the Google Sheet could not be found. It may have been deleted or moved. Please check the spreadsheet URL and that it is shared with our service account.",}def get_schemas(diff --git a/posthog/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.py b/posthog/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.pyindex 2e01f600e4fb..72a12214a7fb 100644--- a/posthog/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.py+++ b/posthog/temporal/data_imports/sources/google_sheets/tests/test_google_sheets.py@@ -101,3 +101,18 @@ def test_permission_error_is_non_retryable():error_msg = str(raised)assert any(key in error_msg for key in non_retryable_errors)+++def test_not_found_api_error_is_non_retryable():+ """gspread raises a 404 APIError when the spreadsheet has been deleted/moved — it+ must match a non-retryable pattern so we stop retrying a permanent failure."""+ mock_response = mock.MagicMock()+ mock_response.json.return_value = {+ "error": {"code": 404, "message": "Requested entity was not found.", "status": "NOT_FOUND"}+ }+ error_msg = str(gspread.exceptions.APIError(mock_response))++ non_retryable_errors = GoogleSheetsSource().get_non_retryable_errors()+ assert any(key in error_msg for key in non_retryable_errors), (+ f"Google Sheets 404 error {error_msg!r} did not match any non-retryable pattern"+ )