: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(salesforce): stop retrying a not-found response and explain it (#107269)
Tom Owers140c735cc533
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.pyindex 3bd25cdca451..2a033c65ef23 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py@@ -57,6 +57,16 @@ class SalesforceSource(ResumableSource[SalesforceSourceConfig, SalesforceResumeC"invalid_session_id": "Your Salesforce session has expired. Please reconnect the source.","400 Client Error: Bad Request for url": None,"403 Client Error: Forbidden for url": None,+ # Salesforce answers 404 on every path of a release an org has not been moved to yet+ # (see `supported_versions` above), and on an object the org does not have. Both are+ # deterministic for the stored pin and the selected table, so retrying replays the same+ # rejection and the raw text echoes the org's instance URL and the SOQL query back to+ # the customer. Match the stable status text, not the volatile url that follows it.+ "404 Client Error: Not Found for url": (+ "Salesforce doesn't have this object, or your org doesn't support the API version "+ "this source uses. Remove the table from the source's selected tables, or contact "+ "support."+ ),"inactive organization": None,# Salesforce's OAuth token endpoint returns error_description "inactive user" when the# user that authorized the connection has been deactivated. Retrying can't fix it —diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.pyindex ce803fe0c570..445bc61df5c0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py@@ -23,6 +23,23 @@ class TestSalesforceSourceNonRetryableErrors:f"Expected '{error_message}' to match a non-retryable pattern")+ def test_not_found_is_non_retryable_with_a_curated_message(self):+ # An org still on the previous Salesforce release answers 404 to every path of the pinned+ # version, so the raw error stores the instance url and the SOQL query verbatim.+ error_message = (+ "404 Client Error: Not Found for url: https://example.my.salesforce.com"+ "/services/data/v67.0/query?q=SELECT+FIELDS%28ALL%29+FROM+Contact"+ )+ non_retryable_errors = self.source.get_non_retryable_errors()++ matched = [pattern for pattern in non_retryable_errors if pattern in error_message]+ assert matched == ["404 Client Error: Not Found for url"]++ friendly = non_retryable_errors[matched[0]]+ assert friendly is not None+ assert "salesforce.com" not in friendly+ assert "404" not in friendly+class TestSalesforceSourceVersions:def setup_method(self):