: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(warehouse-sources): stop a lone 403 from blaming a working API key (#91423)
jake sciottoe582d6c554a4
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.pyindex ce4feb84b803..f3631e72191b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py@@ -75,14 +75,29 @@ You can find your API key on the **Developer** page of the [Decagon dashboard](hreturn CANONICAL_DESCRIPTIONSdef get_non_retryable_errors(self) -> dict[str, str | None]:+ # Insertion order matters: the finalization activity surfaces the first matching+ # pattern's message, so endpoint-specific 403 entries must precede the bare 403 one.+ # A bare 403 does not establish a key problem, because the same key keeps syncing+ # sibling tables when Decagon gates an endpoint on an account plan (#87958). The 403+ # messages therefore point the operator at the sibling-table check instead of the key.return {"401 Client Error: Unauthorized": ("Decagon rejected the API key. Generate a new key on the Developer page of the ""Decagon dashboard and reconnect."),+ "403 Client Error: Forbidden for url: https://api.decagon.ai/agent_assist": (+ "Decagon refused access to the Agent Assist export. If your other Decagon tables "+ "are syncing, the API key works and your Decagon plan likely does not include "+ "Agent Assist. Ask Decagon to enable it, then re-enable the sync. If every table "+ "is failing, generate a new key on the Developer page of the Decagon dashboard "+ "and reconnect."+ ),"403 Client Error: Forbidden": (- "The Decagon API key does not have access to the endpoint behind this table. Check "- "the key on the Developer page of the Decagon dashboard and reconnect."+ "Decagon refused access to the endpoint behind this table. If your other Decagon "+ "tables are syncing, the API key works and your Decagon plan likely does not "+ "include this endpoint. Ask Decagon to enable it, then re-enable the sync. If "+ "every table is failing, generate a new key on the Developer page of the Decagon "+ "dashboard and reconnect."),}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.pyindex 21bc96dea483..da268e54253d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py@@ -97,6 +97,43 @@ class TestDecagonSource:# exception noise.assert error_message_matches(error_msg, self.source.get_retryable_errors())+ @parameterized.expand(+ [+ (+ "agent_assist_403_names_the_plan_gate",+ "403 Client Error: Forbidden for url: "+ "https://api.decagon.ai/agent_assist/actions/export?min_timestamp=0",+ "Agent Assist",+ ),+ (+ "other_endpoint_403_keeps_the_generic_message",+ "403 Client Error: Forbidden for url: https://api.decagon.ai/tag/all",+ "endpoint behind this table",+ ),+ (+ "401_still_maps_to_the_key_message",+ "401 Client Error: Unauthorized for url: https://api.decagon.ai/conversation/export",+ "rejected the API key",+ ),+ ]+ )+ def test_non_retryable_errors_surface_the_most_specific_message(+ self, _name: str, error_msg: str, expected_fragment: str+ ) -> None:+ # Mirrors the finalization activity: the first matching pattern in insertion order+ # decides the message the operator sees, so the agent_assist entry must win over the+ # bare 403 fallback for its own URL and lose it for every other endpoint.+ friendly = next(+ (+ message+ for pattern, message in self.source.get_non_retryable_errors().items()+ if error_message_matches(error_msg, [pattern])+ ),+ None,+ )+ assert friendly is not None+ assert expected_fragment in friendly+@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.decagon.source.validate_decagon_credentials")diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/source.pyindex 0ef5928c3d5e..842d90708e2d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/northpass_lms/source.py@@ -85,7 +85,10 @@ You can create an API key in your Northpass admin panel under **Apps → API Acc# An invalid or revoked API key surfaces as an HTTPError when the REST client calls# `raise_for_status()`. Retrying can never satisfy a credential problem, so stop the sync."401 Client Error: Unauthorized for url: https://api.northpass.com": "Your Northpass API key is invalid or has been revoked. Create a new key in your Northpass admin panel under Apps → API Access, then reconnect.",- "403 Client Error: Forbidden for url: https://api.northpass.com": "Your Northpass API key does not have permission to access this data. Check the key's permissions in your Northpass admin panel, then reconnect.",+ # A bare 403 does not establish a key problem, because the same key keeps syncing+ # sibling tables when Northpass gates an endpoint on an account plan (#87959). The+ # message points the operator at the sibling-table check instead of blaming the key.+ "403 Client Error: Forbidden for url: https://api.northpass.com": "Northpass refused access to the endpoint behind this table. If your other Northpass tables are syncing, the API key works and your Northpass plan likely does not include this endpoint. Ask Northpass support to enable it, then re-enable the sync. If every table is failing, check the key's permissions in your Northpass admin panel, then reconnect.",}def get_schemas(