: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(data-imports): tolerate a deleted issue's 404 in Sentry issue_hashes sync (#78929)
Tom Owers33333f214c50
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/fanout.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/fanout.pyindex cf1eb62cb8a5..a49e3ac458ce 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/fanout.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/fanout.py@@ -11,6 +11,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resEndpoint,EndpointResource,IncrementalConfig,+ ResponseAction,)@@ -31,6 +32,10 @@ class DependentEndpointConfig:parent_field_renames: dict[str, str] = field(default_factory=dict)parent_params: dict[str, Any] = field(default_factory=dict)child_params: dict[str, Any] = field(default_factory=dict)+ # Applied to the CHILD request only. Use this to tolerate a per-parent-item failure (e.g. a+ # 404 for a parent row deleted/merged between the parent listing and this child fetch)+ # without failing the whole fan-out — see resource.py's response_actions "ignore" handling.+ child_response_actions: list[ResponseAction] = field(default_factory=list)def rename_parent_fields(parent_name: str, renames: dict[str, str]) -> Callable[[dict[str, Any]], dict[str, Any]]:@@ -126,6 +131,8 @@ def build_dependent_resource("path": child_path,"params": child_params,}+ if fanout.child_response_actions:+ child_endpoint_config["response_actions"] = fanout.child_response_actionsif child_endpoint_extra:if "params" in child_endpoint_extra:raise ValueError(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/tests/test_fanout.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/tests/test_fanout.pyindex 59982ec85c07..623ab30b5ef1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/tests/test_fanout.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/rest_source/tests/test_fanout.py@@ -182,6 +182,37 @@ def test_build_dependent_resource_merges_fanout_child_params(mock_rest_api_resouassert parent_params == {"limit": 3}+@patch("products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources")+def test_build_dependent_resource_forwards_child_response_actions(mock_rest_api_resources) -> None:+ mock_rest_api_resources.return_value = []+ try:+ build_dependent_resource(+ endpoint_configs=_build_endpoint_configs(),+ child_endpoint="children",+ fanout=DependentEndpointConfig(+ parent_name="parents",+ resolve_param="parent_id",+ resolve_field="id",+ include_from_parent=["id"],+ child_response_actions=[{"status_code": 404, "action": "ignore"}],+ ),+ client_config={"base_url": "https://example.com"},+ path_format_values={},+ team_id=1,+ job_id="job-1",+ db_incremental_field_last_value=None,+ )+ except StopIteration:+ pass++ config = mock_rest_api_resources.call_args.args[0]+ parent_resource = config["resources"][0]+ child_resource = config["resources"][1]+ assert child_resource["endpoint"]["response_actions"] == [{"status_code": 404, "action": "ignore"}]+ # The parent request has no such tolerance — a 404 there still means "org/list not found".+ assert "response_actions" not in parent_resource["endpoint"]++@patch("products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources")def test_build_dependent_resource_rejects_child_params_clobbering_resolve(mock_rest_api_resources) -> None:mock_rest_api_resources.return_value = []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 75e458510a10..36a617b9f587 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@@ -266,6 +266,10 @@ 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"}],),),"issue_tag_values": SentryEndpointConfig(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 edadd515e80b..1d1794bbd724 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@@ -531,6 +531,31 @@ class TestSentrySourceValidation:child_resource = next(r for r in config["resources"] if r["name"] == endpoint)assert child_resource["endpoint"]["params"]["full"] == "true"+ @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+ # SentrySource.get_non_retryable_errors' generic "404 Client Error" mapping).+ mock_rest_api_resources.return_value = [+ _FakeDltResource("issues", [{"id": "100"}]),+ _FakeDltResource("issue_hashes", []),+ ]++ sentry_source(+ auth_token="token",+ organization_slug="acme",+ api_base_url="https://sentry.io",+ endpoint="issue_hashes",+ 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")+ assert child_resource["endpoint"]["response_actions"] == [{"status_code": 404, "action": "ignore"}]+# ----- Issue fan-out: custom iterator (issue_tag_values) -----@patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry.make_tracked_session")