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(sentry): skip issue on persistent tags endpoint server error (#92277)

Tom Owers6dbd4babe48b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py
index 238957f01741..81b055b74f9e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py
@@ -402,6 +402,29 @@ def _skip_rows_on_stale_issue_404(
raise
+def _skip_issue_on_tags_server_error(
+ rows: Iterator[dict[str, Any]], organization_slug: str, issue_id: str
+) -> Iterator[dict[str, Any]]:
+ """Swallow a persistent 5xx raised while iterating an issue's tags endpoint.
+
+ Retries are already exhausted by _request_with_retry; skip this issue's tags
+ rather than failing the whole sync — same graceful-skip as the values endpoint.
+ """
+ try:
+ yield from rows
+ except HTTPError as exc:
+ response = exc.response
+ if response is not None and response.status_code >= 500:
+ logger.warning(
+ "sentry_source.issue_tags_server_error_skipped",
+ organization_slug=organization_slug,
+ issue_id=issue_id,
+ status_code=response.status_code,
+ )
+ return
+ raise
+
+
# lastSeen carries the scan floor, so it is always projected. A parent whose column selection
# dropped it fails the eager resolve check and drives this child from the API instead.
_ISSUES_PARENT_COLUMNS = ["id", "lastSeen"]
@@ -557,7 +580,7 @@ def _iter_issue_tag_values_rows(
# schema last synced; their tags endpoint 404s. A fresh API parent pull would
# simply not list them, so skip instead of failing the sync.
tags = _skip_rows_on_stale_issue_404(tags, organization_slug, issue_id, stale_issues)
- for tag in tags:
+ for tag in _skip_issue_on_tags_server_error(tags, organization_slug, issue_id):
tag_key = tag.get("key") or tag.get("id")
if not isinstance(tag_key, str) or not tag_key:
continue
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
index f331401a8558..2c9d0e05f428 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
@@ -829,6 +829,35 @@ class TestSentrySourceValidation:
with pytest.raises(HTTPError):
list(cast(Any, resp.items()))
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry._request_with_retry")
+ def test_issue_tag_values_skips_issue_on_persistent_tags_server_error(self, mock_request) -> None:
+ def side_effect(url, headers=None, params=None, timeout=None):
+ if url.endswith("/organizations/acme/issues/"):
+ return _response([{"id": "100"}, {"id": "200"}])
+ if url.endswith("/organizations/acme/issues/100/tags/"):
+ # Sentry persistently 503s for this issue's tags endpoint.
+ return _response(None, status_code=503)
+ if url.endswith("/organizations/acme/issues/200/tags/"):
+ return _response([{"key": "browser"}])
+ if url.endswith("/organizations/acme/issues/200/tags/browser/values/"):
+ return _response([{"value": "Chrome"}])
+ return _response([])
+
+ mock_request.side_effect = side_effect
+
+ resp = sentry_source(
+ auth_token="token",
+ organization_slug="acme",
+ api_base_url="https://sentry.io",
+ endpoint="issue_tag_values",
+ team_id=123,
+ job_id="job-id",
+ )
+
+ # The 503 on issue 100's tags endpoint is skipped; issue 200 still yields its values.
+ rows = list(cast(Any, resp.items()))
+ assert rows == [{"value": "Chrome", "issue_id": "200", "tag_key": "browser"}]
+
class TestSentrySourceResumable:
"""Resume behaviour for flat endpoints (rest_api_resource path)."""