: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(twenty): keep transient database errors out of error tracking (#123726)
Tom Owers88bbee8839ee
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/source.pyindex 0418d70a382c..4ccc0c340c95 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/source.py@@ -58,6 +58,13 @@ class TwentySource(ResumableSource[TwentySourceConfig, TwentyResumeConfig]):HTTP_NOT_ALLOWED_ERROR: "The Twenty instance URL must use HTTPS. Please update the instance URL to use https://.",}+ def get_retryable_errors(self) -> set[str]:+ # Twenty returns this as a 400, not a 5xx, so the shared REST client's retry loop (which+ # only reissues 408/429/5xx) never catches it in-process — it reaches here on the first+ # attempt. The code name says the failure is on Twenty's DB, not the request shape, and+ # Temporal's activity retry recovers once it clears, so keep it out of error tracking as noise.+ return {"code=TRANSIENT_DATABASE_ERROR"}+def get_canonical_descriptions(self) -> CanonicalDescriptions:from products.warehouse_sources.backend.temporal.data_imports.sources.twenty.canonical_descriptions import ( # noqa: PLC0415CANONICAL_DESCRIPTIONS,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/tests/test_twenty_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/tests/test_twenty_source.pyindex 854930d77f6e..21dc23ccdb62 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/tests/test_twenty_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/twenty/tests/test_twenty_source.py@@ -11,3 +11,13 @@ class TestTwentySource:def test_connection_host_fields_force_secret_reentry(self):# The API key is sent to base_url, so retargeting it must re-require the key.assert self.source.connection_host_fields == ["base_url"]++ def test_retryable_errors_match_transient_database_error(self):+ # Twenty returns this as a 400, so the shared REST client's own retry loop never retries+ # it; this is what keeps the self-recovering failure out of error tracking as noise.+ observed_error = (+ "400 Client Error: Bad Request for url: https://api.twenty.com/rest/people"+ " | api error: code=TRANSIENT_DATABASE_ERROR"+ )+ retryable_errors = self.source.get_retryable_errors()+ assert any(key in observed_error for key in retryable_errors)