: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(sentry): stop reporting a missing table resource as a missing organization (#111287)
Tom Owers20b5660734e3
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/settings.pyindex 7fd5b8efa242..232caa7af81e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/settings.py@@ -5,7 +5,10 @@ from typing import Any, Literalfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (DependentEndpointConfig,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ParentRowFilter+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (+ ParentRowFilter,+ ResponseAction,+)from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldTypeDEFAULT_SENTRY_API_BASE_URL = "https://sentry.io"@@ -40,6 +43,12 @@ SENTRY_RETENTION_DAYS = 90# warehouse only when an incremental watermark bounds the scan, with this window as the cap.SENTRY_FANOUT_PARENT_WINDOW = timedelta(days=90)+# A parent row (an issue, project, release, repo or monitor) can be deleted, merged or renamed+# between the parent listing and its per-row child fetch, which then 404s. That's expected churn,+# not a broken sync, so treat it as "no children for this row" instead of failing the whole schema+# under the generic "404 Client Error" mapping in `SentrySource.get_non_retryable_errors`.+DELETED_PARENT_RESPONSE_ACTIONS: list[ResponseAction] = [{"status_code": 404, "action": "ignore"}]+ISSUES_PARENT_ROW_FILTER = ParentRowFilter(field="lastSeen", not_older_than=SENTRY_FANOUT_PARENT_WINDOW)# `dataset` values accepted by /trace-items/attributes/.@@ -207,6 +216,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {parent_field_renames={"id": "project_id", "slug": "project_slug"},# full=true makes Sentry return complete event bodies (incl. stacktrace entries).child_params={"full": "true"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"project_users": SentryEndpointConfig(@@ -220,6 +230,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="slug",include_from_parent=["id", "slug"],parent_field_renames={"id": "project_id", "slug": "project_slug"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"project_client_keys": SentryEndpointConfig(@@ -234,6 +245,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="slug",include_from_parent=["id", "slug"],parent_field_renames={"id": "project_id", "slug": "project_slug"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"project_service_hooks": SentryEndpointConfig(@@ -248,6 +260,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="slug",include_from_parent=["id", "slug"],parent_field_renames={"id": "project_id", "slug": "project_slug"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"issue_events": SentryEndpointConfig(@@ -272,6 +285,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {# Not "warehouse": the issues listing is clamped by per-org event retention, which a# snapshot scan cannot reproduce — see SENTRY_FANOUT_PARENT_WINDOW.parent_source="api",+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"issue_hashes": SentryEndpointConfig(@@ -286,10 +300,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {include_from_parent=["id"],parent_field_renames={"id": "issue_id"},parent_params={"query": "", "sort": "date"},- # An issue can be deleted or merged into another between the `issues` listing and- # this per-issue fetch, which 404s. That's expected churn, not a broken sync — treat- # it as "no hashes for this issue" instead of failing the whole schema.- child_response_actions=[{"status_code": 404, "action": "ignore"}],+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,# Not "warehouse": same per-org retention clamp as issue_events.parent_source="api",),@@ -458,6 +469,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="version",include_from_parent=["version"],parent_field_renames={"version": "release_version"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"release_commits": SentryEndpointConfig(@@ -473,6 +485,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="version",include_from_parent=["version"],parent_field_renames={"version": "release_version"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"repo_commits": SentryEndpointConfig(@@ -488,6 +501,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="id",include_from_parent=["id"],parent_field_renames={"id": "repo_id"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"monitor_checkins": SentryEndpointConfig(@@ -503,6 +517,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="id",include_from_parent=["id"],parent_field_renames={"id": "monitor_id"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"project_user_feedback": SentryEndpointConfig(@@ -518,6 +533,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="slug",include_from_parent=["id", "slug"],parent_field_renames={"id": "project_id", "slug": "project_slug"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),"project_filters": SentryEndpointConfig(@@ -532,6 +548,7 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {resolve_field="slug",include_from_parent=["id", "slug"],parent_field_renames={"id": "project_id", "slug": "project_slug"},+ child_response_actions=DELETED_PARENT_RESPONSE_ACTIONS,),),}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.pyindex 92606b50b8c5..e81707fce55f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py@@ -126,7 +126,13 @@ class SentrySource(ResumableSource[SentrySourceConfig, SentryResumeConfig]):"403 Client Error": "Sentry token is missing required scopes. Make sure it includes the scopes required for your schemas — the full set is: "+ ", ".join(REQUIRED_SENTRY_SCOPES)+ ".",- "404 Client Error": "Sentry organization not found. Verify your organization slug.",+ # The org itself is checked when the source is set up, so a 404 here is most often an+ # org-level table behind a Sentry plan feature the org doesn't have. A slug renamed+ # since setup 404s the same way.+ "404 Client Error": (+ "Sentry couldn't find this table for your organization. Check that your plan includes it "+ "and the organization slug is correct, or turn off syncing for this table."+ ),# Raised as `SentryStatsSummaryRejectedError` for any stats-summary 400 other than the# skipped no-projects case (see sentry.py). Deterministic for the request we build, so# stop retrying; the message is defined at the raise site so it stays credential-safe.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.pyindex ae8584501d5d..beadcf79bbcc 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@@ -45,6 +45,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.sentry.souCUSTOM_ITERATOR_ENDPOINTS = [name for name, config in SENTRY_ENDPOINTS.items() if config.custom_iterator and name != "issue_tag_values"]+_FANOUT_ENDPOINTS = [(name, config.fanout.parent_name) for name, config in SENTRY_ENDPOINTS.items() if config.fanout]def _response(payload, status_code: int = 200, link_header: str = "") -> Mock:@@ -619,29 +620,30 @@ class TestSentrySourceValidation:child_resource = next(r for r in config["resources"] if r["name"] == endpoint)assert child_resource["endpoint"]["params"]["full"] == "true"+ @parameterized.expand(_FANOUT_ENDPOINTS)@patch("products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources")- def test_issue_hashes_tolerates_child_not_found(self, mock_rest_api_resources) -> None:- # An issue can be deleted/merged between the `issues` listing and this per-issue hashes- # fetch, which 404s. That single-issue 404 must not fail the whole schema (see+ def test_fanout_tolerates_child_not_found(self, endpoint, parent_name, mock_rest_api_resources) -> None:+ # A parent row can be deleted, merged or renamed between the parent listing and its child+ # fetch, which 404s. That single-row 404 must not fail the whole schema (see# SentrySource.get_non_retryable_errors' generic "404 Client Error" mapping).mock_rest_api_resources.return_value = [- _FakeDltResource("issues", [{"id": "100"}]),- _FakeDltResource("issue_hashes", []),+ _FakeDltResource(parent_name, []),+ _FakeDltResource(endpoint, []),]sentry_source(auth_token="token",organization_slug="acme",api_base_url="https://sentry.io",- endpoint="issue_hashes",+ endpoint=endpoint,team_id=123,job_id="job-id",)config = mock_rest_api_resources.call_args.args[0]- child_resource = next(r for r in config["resources"] if r["name"] == "issue_hashes")+ child_resource = next(r for r in config["resources"] if r["name"] == endpoint)assert child_resource["endpoint"]["response_actions"] == [{"status_code": 404, "action": "ignore"}]# ----- Issue fan-out: custom iterator (issue_tag_values) -----