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(monday): retry monday.com internal server errors instead of failing the sync (#72697)

Tom Owers076316060b32
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
index 47abd3692791..cc6adff63f73 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
@@ -148,9 +148,13 @@ def _execute(
errors = body.get("errors")
if errors:
message = "; ".join(str(error.get("message", error)) for error in errors)
- # Complexity-budget exhaustion comes back as a GraphQL error, not a 429.
- if "complexity" in message.lower():
+ message_lower = message.lower()
+ # Complexity-budget exhaustion and transient backend failures both come back
+ # as a 200 with a GraphQL error, not a 429/5xx status.
+ if "complexity" in message_lower:
raise MondayRetryableError(f"monday.com complexity budget exhausted: {message}")
+ if "internal server error" in message_lower:
+ raise MondayRetryableError(f"monday.com internal server error (retryable): {message}")
raise MondayGraphQLError(f"monday.com GraphQL error: {message}")
return body.get("data") or {}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
index 0a35dcaaed57..38e8b8b12dde 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
@@ -7,6 +7,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.monday.mon
ITEMS_PAGE_SIZE,
PAGE_SIZE,
MondayGraphQLError,
+ MondayRetryableError,
get_rows,
monday_source,
validate_credentials,
@@ -73,6 +74,27 @@ class TestGetRowsPaged:
with pytest.raises(MondayGraphQLError):
list(get_rows("token", "users", mock.MagicMock()))
+ @mock.patch("time.sleep")
+ @mock.patch(f"{_MODULE}.make_tracked_session")
+ def test_internal_server_error_is_retried_then_succeeds(self, mock_session, _mock_sleep):
+ mock_session.return_value.post.side_effect = [
+ _response({}, errors=[{"message": "Internal Server Error"}]),
+ _response({"users": [{"id": "1"}]}),
+ ]
+
+ batches = list(get_rows("token", "users", mock.MagicMock()))
+
+ assert batches == [[{"id": "1"}]]
+ assert mock_session.return_value.post.call_count == 2
+
+ @mock.patch("time.sleep")
+ @mock.patch(f"{_MODULE}.make_tracked_session")
+ def test_internal_server_error_raises_retryable_when_exhausted(self, mock_session, _mock_sleep):
+ mock_session.return_value.post.return_value = _response({}, errors=[{"message": "Internal Server Error"}])
+
+ with pytest.raises(MondayRetryableError):
+ list(get_rows("token", "users", mock.MagicMock()))
+
@mock.patch(f"{_MODULE}.make_tracked_session")
def test_requests_carry_token_and_api_version(self, mock_session):
mock_session.return_value.post.return_value = _response({"users": []})