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.

feat(data-warehouse): sync full sentry event bodies in fanout children (#74319)

Daniel RC2f225605f5bf
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.py
index 121c3bd4c7ec..cf1eb62cb8a5 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
@@ -30,6 +30,7 @@ class DependentEndpointConfig:
include_from_parent: list[str]
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)
def rename_parent_fields(parent_name: str, renames: dict[str, str]) -> Callable[[dict[str, Any]], dict[str, Any]]:
@@ -111,6 +112,14 @@ def build_dependent_resource(
}
if page_size_param is not None:
child_params[page_size_param] = child_config.page_size
+ # The resolve param binds child requests to their parent row. A config that reuses that key
+ # would clobber the binding, so reject it loudly rather than silently dropping the value.
+ if fanout.resolve_param in fanout.child_params:
+ raise ValueError(
+ f"child_params must not include the resolve param '{fanout.resolve_param}'; "
+ "it is managed by build_dependent_resource."
+ )
+ child_params.update(fanout.child_params)
if child_params_extra:
child_params.update(child_params_extra)
child_endpoint_config: Endpoint = {
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.py
index 6b49eb0c3320..59982ec85c07 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
@@ -139,12 +139,72 @@ def test_build_dependent_resource_backwards_compatible_defaults(mock_rest_api_re
config = mock_rest_api_resources.call_args.args[0]
parent_resource = config["resources"][0]
child_resource = config["resources"][1]
- assert parent_resource["endpoint"]["params"]["limit"] == 3
- assert child_resource["endpoint"]["params"]["limit"] == 7
+ assert parent_resource["endpoint"]["params"] == {"limit": 3}
+ assert child_resource["endpoint"]["params"] == {
+ "parent_id": {"type": "resolve", "resource": "parents", "field": "id"},
+ "limit": 7,
+ }
assert "data_selector" not in parent_resource["endpoint"]
assert "data_selector" not in child_resource["endpoint"]
+@patch("products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources")
+def test_build_dependent_resource_merges_fanout_child_params(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_params={"full": "true"},
+ ),
+ 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_params = config["resources"][0]["endpoint"]["params"]
+ child_params = config["resources"][1]["endpoint"]["params"]
+ assert child_params == {
+ "parent_id": {"type": "resolve", "resource": "parents", "field": "id"},
+ "limit": 7,
+ "full": "true",
+ }
+ assert 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_rejects_child_params_clobbering_resolve(mock_rest_api_resources) -> None:
+ mock_rest_api_resources.return_value = []
+
+ with pytest.raises(ValueError, match="must not include the resolve param 'parent_id'"):
+ 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_params={"parent_id": "would-clobber-resolve"},
+ ),
+ client_config={"base_url": "https://example.com"},
+ path_format_values={},
+ team_id=1,
+ job_id="job-1",
+ db_incremental_field_last_value=None,
+ )
+
+
@patch("products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources")
def test_build_dependent_resource_threads_resume_state(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.py
index 1c0b2a54de63..75e458510a10 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
@@ -191,6 +191,8 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {
resolve_field="slug",
include_from_parent=["id", "slug"],
parent_field_renames={"id": "project_id", "slug": "project_slug"},
+ # full=true makes Sentry return complete event bodies (incl. stacktrace entries).
+ child_params={"full": "true"},
),
),
"project_users": SentryEndpointConfig(
@@ -248,6 +250,8 @@ SENTRY_ENDPOINTS: dict[str, SentryEndpointConfig] = {
include_from_parent=["id"],
parent_field_renames={"id": "issue_id"},
parent_params={"query": "", "sort": "date"},
+ # full=true makes Sentry return complete event bodies (incl. stacktrace entries).
+ child_params={"full": "true"},
),
),
"issue_hashes": 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.py
index 3cc95906db24..608c61be7343 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
@@ -472,6 +472,34 @@ class TestSentrySourceValidation:
assert row["issue_id"] == "100"
assert "_issues_id" not in row
+ @parameterized.expand(
+ [
+ ("issue_events", "issues"),
+ ("project_events", "projects"),
+ ]
+ )
+ @patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources"
+ )
+ def test_event_fanout_requests_full_event_bodies(self, endpoint, parent_name, mock_rest_api_resources) -> None:
+ mock_rest_api_resources.return_value = [
+ _FakeDltResource(parent_name, []),
+ _FakeDltResource(endpoint, []),
+ ]
+
+ sentry_source(
+ auth_token="token",
+ organization_slug="acme",
+ api_base_url="https://sentry.io",
+ 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"] == endpoint)
+ assert child_resource["endpoint"]["params"]["full"] == "true"
+
# ----- Issue fan-out: custom iterator (issue_tag_values) -----
@patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry.make_tracked_session")