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): link sync warnings to source management page (#60640)

Tom Owers307850814d53
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index c97dc345c532..aa85f9425075 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -14595,6 +14595,10 @@
"description": "Name of the ExternalDataSchema responsible for syncing the table",
"type": "string"
},
+ "source_id": {
+ "description": "ID of the ExternalDataSource, used to link to its management page. Null for self-managed tables.",
+ "type": ["string", "null"]
+ },
"source_type": {
"description": "Source type, e.g. \"Stripe\", \"Hubspot\"",
"type": "string"
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 5fdfcba6a2d9..e99675f375e4 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -479,6 +479,8 @@ export interface DataWarehouseSyncWarning {
schema_name: string
/** Source type, e.g. "Stripe", "Hubspot" */
source_type: string
+ /** ID of the ExternalDataSource, used to link to its management page. Null for self-managed tables. */
+ source_id?: string | null
/** Sync status that triggered the warning, e.g. "Failed", "Paused", "BillingLimitReached" */
status: string
/** Human-readable warning shown to the user */
diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
index ea1bf0bbe8db..29c89cbaec41 100644
--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
@@ -28,11 +28,13 @@ import { Resizer } from 'lib/components/Resizer/Resizer'
import { type ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'
import { TZLabel } from 'lib/components/TZLabel'
import { IconTableChart } from 'lib/lemon-ui/icons'
+import { Link } from 'lib/lemon-ui/Link'
import { LoadingBar } from 'lib/lemon-ui/LoadingBar'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { transformDataTableToDataTableRows } from 'lib/utils/dataTableTransformations'
import { InsightErrorState, StatelessInsightLoadingState } from 'scenes/insights/EmptyStates'
import { HogQLBoldNumber } from 'scenes/insights/views/BoldNumber/BoldNumber'
+import { urls } from 'scenes/urls'
import { KeyboardShortcut } from '~/layout/navigation-3000/components/KeyboardShortcut'
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
@@ -957,7 +959,17 @@ const SyncWarningsBanner = ({ warnings }: { warnings?: HogQLQueryResponse['warni
</div>
<ul className="list-disc pl-5 space-y-1">
{warnings.map((warning, index) => (
- <li key={`${warning.table_name}-${warning.schema_name}-${index}`}>{warning.message}</li>
+ <li key={`${warning.table_name}-${warning.schema_name}-${index}`}>
+ {warning.message}
+ {warning.source_id && (
+ <>
+ {' '}
+ <Link to={urls.dataWarehouseSource(`managed-${warning.source_id}`)} target="_blank">
+ Manage source
+ </Link>
+ </>
+ )}
+ </li>
))}
</ul>
</LemonBanner>
diff --git a/posthog/schema.py b/posthog/schema.py
index 9a8e01808fcb..e0acb90e2613 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -1426,6 +1426,12 @@ class DataWarehouseSyncWarning(BaseModel):
...,
description="Name of the ExternalDataSchema responsible for syncing the table",
)
+ source_id: str | None = Field(
+ default=None,
+ description=(
+ "ID of the ExternalDataSource, used to link to its management page. Null for self-managed tables."
+ ),
+ )
source_type: str = Field(..., description='Source type, e.g. "Stripe", "Hubspot"')
status: str = Field(
...,
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index c9ebfb70fa34..e5663ef03d07 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -1095,6 +1095,8 @@ export interface DataWarehouseSyncWarningApi {
message: string
/** Name of the ExternalDataSchema responsible for syncing the table */
schema_name: string
+ /** ID of the ExternalDataSource, used to link to its management page. Null for self-managed tables. */
+ source_id?: string | null
/** Source type, e.g. "Stripe", "Hubspot" */
source_type: string
/** Sync status that triggered the warning, e.g. "Failed", "Paused", "BillingLimitReached" */
diff --git a/products/data_warehouse/backend/sync_status.py b/products/data_warehouse/backend/sync_status.py
index 31896a98d881..5dee8d77d2aa 100644
--- a/products/data_warehouse/backend/sync_status.py
+++ b/products/data_warehouse/backend/sync_status.py
@@ -57,12 +57,14 @@ def _build_warning_for_schema(
) -> DataWarehouseSyncWarning | None:
schema_status = schema.status
source_type = schema.source.source_type if schema.source_id else "unknown"
+ source_id = str(schema.source_id) if schema.source_id else None
def build(*, status: str, message: str) -> DataWarehouseSyncWarning:
return DataWarehouseSyncWarning(
table_name=table_name,
schema_name=schema.name,
source_type=source_type,
+ source_id=source_id,
status=status,
message=message,
)
diff --git a/products/data_warehouse/backend/test/test_sync_status.py b/products/data_warehouse/backend/test/test_sync_status.py
index 54285b01ca00..02e398684f72 100644
--- a/products/data_warehouse/backend/test/test_sync_status.py
+++ b/products/data_warehouse/backend/test/test_sync_status.py
@@ -103,6 +103,7 @@ class TestWarehouseSyncWarnings(BaseTest):
assert warning.table_name == "stripe_charge"
assert warning.schema_name == "Charge"
assert warning.source_type == ExternalDataSourceType.STRIPE
+ assert warning.source_id == str(self.source.id)
assert warning.status == str(status)
assert "stripe_charge" in warning.message
@@ -128,6 +129,7 @@ class TestWarehouseSyncWarnings(BaseTest):
warnings = get_warehouse_sync_warnings(self.table, now=self.now)
assert len(warnings) == 1
assert warnings[0].status == str(ExternalDataSchema.Status.RUNNING)
+ assert warnings[0].source_id == str(self.source.id)
assert "more than twice" in warnings[0].message
def test_no_warning_when_running_at_exact_threshold(self) -> None:
@@ -157,6 +159,7 @@ class TestWarehouseSyncWarnings(BaseTest):
warnings = get_warehouse_sync_warnings(self.table, now=self.now)
assert len(warnings) == 1
assert "paused" in warnings[0].message.lower()
+ assert warnings[0].source_id == str(self.source.id)
# status must be consistent with the "paused" message, not the raw schema status (Completed).
assert warnings[0].status == ExternalDataSchema.Status.PAUSED
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 2ab354d363d9..b8ffd99e783a 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -788,6 +788,8 @@ export interface DataWarehouseSyncWarningApi {
message: string
/** Name of the ExternalDataSchema responsible for syncing the table */
schema_name: string
+ /** ID of the ExternalDataSource, used to link to its management page. Null for self-managed tables. */
+ source_id?: string | null
/** Source type, e.g. "Stripe", "Hubspot" */
source_type: string
/** Sync status that triggered the warning, e.g. "Failed", "Paused", "BillingLimitReached" */
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cf2fca7a54df..f076fbb1f5ab 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -456,6 +456,8 @@ export namespace Schemas {
message: string;
/** Name of the ExternalDataSchema responsible for syncing the table */
schema_name: string;
+ /** ID of the ExternalDataSource, used to link to its management page. Null for self-managed tables. */
+ source_id?: string | null;
/** Source type, e.g. "Stripe", "Hubspot" */
source_type: string;
/** Sync status that triggered the warning, e.g. "Failed", "Paused", "BillingLimitReached" */