Skip to content

: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.

fix(chatwoot): stop retrying a 422 from the reporting_events sync (#123352)

Tom Owers2121dd2988a9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/source.py
index 4e3a5a0c159f..db622baceba6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/source.py
@@ -183,6 +183,10 @@ If automatic creation failed, note that only Chatwoot administrators can manage
"401 Client Error": "Chatwoot rejected your API access token. Check the token is correct, has not been revoked, and belongs to a member of the configured account, then reconnect.",
"403 Client Error": "Your Chatwoot API access token does not have permission to read this data. Use an administrator's access token, then reconnect.",
"404 Client Error": "Chatwoot could not find the configured account. Check the account ID and instance URL, then reconnect.",
+ # Chatwoot rejected a page/window combination as unprocessable. Page number and the
+ # since/until window are deterministic (the resume bookmark replays the same request),
+ # so retrying never changes the outcome.
+ "422 Client Error": "Chatwoot rejected a request while syncing this data. Please contact support if this persists.",
REPORTING_EVENTS_UNAVAILABLE_ERROR: "This Chatwoot instance does not serve reporting events. The endpoint only exists on Chatwoot Cloud and enterprise builds, so deselect the reporting_events table to sync the rest.",
INVALID_ACCOUNT_ID_ERROR: "The Chatwoot account ID must be a number (the number in your Chatwoot URL, e.g. app.chatwoot.com/app/accounts/1). Update the source configuration.",
HOST_NOT_ALLOWED_ERROR: "The Chatwoot host is not allowed. Please use a publicly reachable instance URL.",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/tests/test_chatwoot.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/tests/test_chatwoot.py
index 5e3aac159326..48ea36d64c71 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/tests/test_chatwoot.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/tests/test_chatwoot.py
@@ -393,6 +393,25 @@ class TestGetRowsReportingEvents:
assert isinstance(result.raised, Exception)
assert REPORTING_EVENTS_UNAVAILABLE_ERROR in str(result.raised)
+ def test_422_is_not_retried_and_matches_a_user_message(self):
+ # The resume bookmark replays the same page and window, so a 422 never changes on retry.
+ result = _driver().run(
+ "reporting_events", [ScriptedResponse(status=422, json={"error": "Unprocessable Content"})]
+ )
+
+ assert isinstance(result.raised, requests.HTTPError)
+ assert len(result.requests) == 1
+ matches = [
+ message
+ for pattern, message in ChatwootSource().get_non_retryable_errors().items()
+ if pattern in str(result.raised)
+ ]
+ # Pin the actual message, not just that one pattern matched — a key that mapped to None
+ # or the wrong text would otherwise still pass.
+ assert matches == [
+ "Chatwoot rejected a request while syncing this data. Please contact support if this persists."
+ ]
+
class TestWebhookTableTransformer:
def test_message_events_are_normalized_to_the_rest_shape(self):