: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(gong): stop retrying library folders when Call Library isn't enabled (#123665)
Tom Owers0e288ff5f703
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.pyindex 143186c720ee..707c540c2bf2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.py@@ -141,6 +141,10 @@ To also sync these tables, additionally grant the scope listed next to each:return {f"401 Client Error: Unauthorized for url: {GONG_BASE_URL}": "Your Gong access key or secret is invalid. Please generate new credentials and reconnect.",f"403 Client Error: Forbidden for url: {GONG_BASE_URL}": "Your Gong credentials do not have the required permissions. Please check the granted scopes and try again.",+ # Gong rejects this request outright (not the empty-window 404 the endpoint otherwise+ # expects) when the account's Call Library feature isn't enabled — every retry replays+ # the same unfiltered request and fails identically.+ f"400 Client Error: Bad Request for url: {GONG_BASE_URL}/v2/library/folders": "Your Gong account doesn't have the Call Library feature enabled, so library folders can't be listed. Disable the library_folders and library_folder_calls tables, or contact Gong to enable Call Library access, then try again.",}def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[GongResumeConfig]:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.pyindex d2382a420e3f..258ad7dd1587 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py@@ -5,6 +5,7 @@ import time_machinefrom parameterized import parameterized+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matchesfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (ScriptedResponse,SourceDriver,@@ -149,6 +150,39 @@ class TestWindowedCalls:assert result.requests[0].param("fromDateTime") == _format_datetime(resume_start)+class TestLibraryFolders400IsNonRetryable:+ # 401/403/429/500/timeout are already covered for every source, Gong included, by+ # `sources/tests/test_source_error_contract.py`. Only the library_folders-specific 400 needs a+ # test here.+ @parameterized.expand(+ [+ ("library_folders", "library_folders", [ScriptedResponse(status=400)]),+ # library_folder_calls fans out from a library_folders listing, so the same account-level+ # rejection surfaces here too, on the parent lookup.+ ("library_folder_calls", "library_folder_calls", [ScriptedResponse(status=400)]),+ ]+ )+ def test_classified_non_retryable(self, _name: str, endpoint: str, responses: list[ScriptedResponse]) -> None:+ result = _driver().run(endpoint, responses)++ assert result.raised is not None+ assert error_message_matches(str(result.raised), GongSource().get_non_retryable_errors())++ def test_same_status_on_a_different_endpoint_stays_retryable(self) -> None:+ # A 400 elsewhere in the API must still surface rather than be swallowed as if it were the+ # account-level library_folders rejection.+ last_value = datetime.now(UTC) - timedelta(days=5)+ result = _driver().run(+ "calls",+ [ScriptedResponse(status=400)],+ should_use_incremental_field=True,+ db_incremental_field_last_value=last_value,+ )++ assert result.raised is not None+ assert not error_message_matches(str(result.raised), GongSource().get_non_retryable_errors())++class TestGongSource:@parameterized.expand([