: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-warehouse): publish latest_history_id as a uuid in the schema (#101246)
Jovan Sakovicbe2b47fb5551
diff --git a/products/data_warehouse/backend/presentation/views/saved_query/editing.py b/products/data_warehouse/backend/presentation/views/saved_query/editing.pyindex 1cae1231c480..512fe4a26af6 100644--- a/products/data_warehouse/backend/presentation/views/saved_query/editing.py+++ b/products/data_warehouse/backend/presentation/views/saved_query/editing.py@@ -1,5 +1,6 @@"""The writable saved-query serializer: validation, create, and update."""+import uuidfrom typing import Any, castfrom django.conf import settings@@ -93,7 +94,12 @@ class DataWarehouseSavedQuerySerializer(sync_frequency_bounds = serializers.SerializerMethodField(read_only=True, help_text=sync_cadence.SYNC_FREQUENCY_BOUNDS_HELP_TEXT)- latest_history_id = serializers.SerializerMethodField(read_only=True)+ latest_history_id = serializers.SerializerMethodField(+ read_only=True,+ help_text="Activity log ID of the most recent query edit to this view. Send it back as "+ "edited_history_id on the next query write, so conflict detection can tell whether someone else "+ "changed the query in the meantime. Edits that leave the query alone do not advance it.",+ )last_run_at = serializers.SerializerMethodField(read_only=True)status = serializers.SerializerMethodField(read_only=True)latest_error = serializers.SerializerMethodField(read_only=True)@@ -220,8 +226,8 @@ class DataWarehouseSavedQuerySerializer(saved_query=view, column_name="").delete()- @extend_schema_field(serializers.IntegerField(allow_null=True))- def get_latest_history_id(self, view: DataWarehouseSavedQuery):+ @extend_schema_field(serializers.UUIDField(allow_null=True))+ def get_latest_history_id(self, view: DataWarehouseSavedQuery) -> uuid.UUID | None:# First check if we have an activity log from a recent creation/updateif ("activity_log" in self.context@@ -231,10 +237,7 @@ class DataWarehouseSavedQuerySerializer(return self.context["activity_log"].id# Otherwise check for annotated field from queryset- if hasattr(view, "latest_activity_id"):- return view.latest_activity_id-- return None+ return cast(uuid.UUID | None, getattr(view, "latest_activity_id", None))@extend_schema_field(serializers.DictField(diff --git a/products/data_warehouse/frontend/generated/api.schemas.ts b/products/data_warehouse/frontend/generated/api.schemas.tsindex c54428b64271..2537d9a3bcb0 100644--- a/products/data_warehouse/frontend/generated/api.schemas.ts+++ b/products/data_warehouse/frontend/generated/api.schemas.ts@@ -1495,8 +1495,11 @@ export interface DataWarehouseSavedQueryApi {* @nullable*/edited_history_id?: string | null- /** @nullable */- readonly latest_history_id: number | null+ /**+ * Activity log ID of the most recent query edit to this view. Send it back as edited_history_id on the next query write, so conflict detection can tell whether someone else changed the query in the meantime. Edits that leave the query alone do not advance it.+ * @nullable+ */+ readonly latest_history_id: string | null/*** If true, skip column inference and validation. For saving drafts.* @nullable@@ -1619,8 +1622,11 @@ export interface PatchedDataWarehouseSavedQueryApi {* @nullable*/edited_history_id?: string | null- /** @nullable */- readonly latest_history_id?: number | null+ /**+ * Activity log ID of the most recent query edit to this view. Send it back as edited_history_id on the next query write, so conflict detection can tell whether someone else changed the query in the meantime. Edits that leave the query alone do not advance it.+ * @nullable+ */+ readonly latest_history_id?: string | null/*** If true, skip column inference and validation. For saving drafts.* @nullablediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex ed288eb13eed..3fa7a8b03a64 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -23889,8 +23889,11 @@ export namespace Schemas {* @nullable*/edited_history_id?: string | null;- /** @nullable */- readonly latest_history_id: number | null;+ /**+ * Activity log ID of the most recent query edit to this view. Send it back as edited_history_id on the next query write, so conflict detection can tell whether someone else changed the query in the meantime. Edits that leave the query alone do not advance it.+ * @nullable+ */+ readonly latest_history_id: string | null;/*** If true, skip column inference and validation. For saving drafts.* @nullable@@ -65383,8 +65386,11 @@ export namespace Schemas {* @nullable*/edited_history_id?: string | null;- /** @nullable */- readonly latest_history_id?: number | null;+ /**+ * Activity log ID of the most recent query edit to this view. Send it back as edited_history_id on the next query write, so conflict detection can tell whether someone else changed the query in the meantime. Edits that leave the query alone do not advance it.+ * @nullable+ */+ readonly latest_history_id?: string | null;/*** If true, skip column inference and validation. For saving drafts.* @nullable