: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(clickhouse_cloud): send millisecond-precision from_date to the activities endpoint (#96728)
Tom Owers70db53a60e79
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/clickhouse_cloud.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/clickhouse_cloud.pyindex f93179a16819..4ce4ea8e40c6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/clickhouse_cloud.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/clickhouse_cloud.py@@ -134,14 +134,19 @@ def _coerce_date(value: Any) -> date | None:def _format_rfc3339(value: Any) -> str:- """Format a datetime/date as an RFC 3339 UTC timestamp with a Z suffix."""+ """Format a datetime/date as an RFC 3339 UTC timestamp with a Z suffix.++ The activities endpoint's `from_date` rejects a timestamp with no fractional-seconds+ component (or one with a precision other than milliseconds) with a 400, so the millisecond+ part is always included even when it's zero.+ """if isinstance(value, datetime):dt = value.replace(tzinfo=UTC) if value.tzinfo is None else value.astimezone(UTC)elif isinstance(value, date):dt = datetime.combine(value, datetime.min.time(), tzinfo=UTC)else:return str(value)- return dt.strftime("%Y-%m-%dT%H:%M:%SZ")+ return dt.strftime("%Y-%m-%dT%H:%M:%S.") + f"{dt.microsecond // 1000:03d}Z"def _list_organizations(session: requests.Session, logger: FilteringBoundLogger) -> list[dict[str, Any]]:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/tests/test_clickhouse_cloud.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/tests/test_clickhouse_cloud.pyindex fe1f6a0e811f..8e07c6599016 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/tests/test_clickhouse_cloud.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse_cloud/tests/test_clickhouse_cloud.py@@ -187,7 +187,7 @@ class TestActivities:should_use_incremental_field=True,db_incremental_field_last_value=datetime(2026, 6, 30, tzinfo=UTC),)- assert "from_date=2026-06-30T00%3A00%3A00Z" in calls[1]+ assert "from_date=2026-06-30T00%3A00%3A00.000Z" in calls[1]assert [r["id"] for r in rows] == ["a-1", "a-2"]def test_full_refresh_omits_from_date(self, monkeypatch: Any) -> None: