: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(warehouse): coerce Intercom epoch attributes to string (#75480)
Daniel RCdc4ac11bb3a9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.pyindex 98598622682a..7cacdf11490e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.py@@ -102,7 +102,19 @@ INTERCOM_ENDPOINTS: dict[str, IntercomEndpointConfig] = {paginator_kind="search",method="POST",partition_key="created_at",- coerce_string_fields=["owner_id"],+ # owner_id flips int/string per row; the nullable epoch attributes flip the+ # same way (each observed failing prod syncs), so the whole family is pinned.+ coerce_string_fields=[+ "owner_id",+ "last_seen_at",+ "last_replied_at",+ "last_contacted_at",+ "last_email_opened_at",+ "last_email_clicked_at",+ "ios_last_seen_at",+ "android_last_seen_at",+ "signed_up_at",+ ],),"conversations": IntercomEndpointConfig(name="conversations",@@ -111,7 +123,7 @@ INTERCOM_ENDPOINTS: dict[str, IntercomEndpointConfig] = {paginator_kind="search",method="POST",partition_key="created_at",- coerce_string_fields=["admin_assignee_id", "team_assignee_id"],+ coerce_string_fields=["admin_assignee_id", "team_assignee_id", "waiting_since", "snoozed_until"],),"tickets": IntercomEndpointConfig(# `POST /tickets/search` mirrors contacts/conversations: it acceptsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.pyindex dcca7164817b..be5ea503a11e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.py@@ -271,6 +271,30 @@ class TestCoerceStringFields:assert data_map is not Noneassert data_map({"owner_id": 7, "id": "c1"}) == {"owner_id": "7", "id": "c1"}+ @pytest.mark.parametrize(+ "field",+ [+ "last_seen_at",+ "last_replied_at",+ "last_contacted_at",+ "last_email_opened_at",+ "last_email_clicked_at",+ "ios_last_seen_at",+ "android_last_seen_at",+ "signed_up_at",+ ],+ )+ def test_contacts_data_map_coerces_epoch_attributes(self, field: str):+ # Intercom returns each nullable epoch attribute as an int on some rows and a+ # string on others, so every one must be pinned to string before rows hit Arrow.+ resource = get_resource(+ "contacts", should_use_incremental_field=False, incremental_field=None, db_incremental_field_last_value=None+ )+ data_map = resource.get("data_map")+ assert data_map is not None+ assert data_map({"id": "c1", field: 1700000000}) == {"id": "c1", field: "1700000000"}+ assert data_map({"id": "c2", field: None}) == {"id": "c2", field: None}+@pytest.mark.parametrize("name", ["conversations", "tickets"])def test_assignee_ids_data_map_coerces_to_str(self, name: str):# REST-path wiring for both streams carrying flat assignee ids: Intercom returns@@ -293,6 +317,22 @@ class TestCoerceStringFields:"team_assignee_id": "678",}+ @pytest.mark.parametrize("field", ["waiting_since", "snoozed_until"])+ def test_conversations_data_map_coerces_epoch_attributes(self, field: str):+ # The parent conversations stream carries its own top-level epoch attributes with+ # the same int-or-string flip as the conversation_parts substream. Coercing only+ # the substream left conversations syncs failing on int64-vs-string merges.+ resource = get_resource(+ "conversations",+ should_use_incremental_field=False,+ incremental_field=None,+ db_incremental_field_last_value=None,+ )+ data_map = resource.get("data_map")+ assert data_map is not None+ assert data_map({"id": "1", field: 1700000000}) == {"id": "1", field: "1700000000"}+ assert data_map({"id": "2", field: None}) == {"id": "2", field: None}+def test_endpoint_without_coerce_fields_has_no_data_map(self):# Only endpoints declaring coerce_string_fields get a data_map — others stay untouched.resource = get_resource(