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.

fix(managed-warehouse): name the failing tables on warehouse readiness (#115974)

Chris Shine7a5e43a6d716
diff --git a/products/data_warehouse/backend/logic/managed_warehouse_data_status.py b/products/data_warehouse/backend/logic/managed_warehouse_data_status.py
index 7bf17235b051..a01b977af602 100644
--- a/products/data_warehouse/backend/logic/managed_warehouse_data_status.py
+++ b/products/data_warehouse/backend/logic/managed_warehouse_data_status.py
@@ -191,7 +191,9 @@ def source_table_readiness(state: ManagedWarehouseSourceJobRecord | None) -> tup
workflow_name = state.workflow_type.value
if state.status == ManagedWarehouseSourceJobStatus.FAILED:
- return "needs_attention", f"The latest {workflow_name} workflow failed. Retry the source sync."
+ return "needs_attention", (
+ f"The latest {workflow_name} workflow failed. To retry, select Sync now for this table on its source page."
+ )
if state.status == ManagedWarehouseSourceJobStatus.RUNNING:
return "backfilling", f"The {workflow_name} workflow is applying the latest source import."
if state.status == ManagedWarehouseSourceJobStatus.COMPLETED:
@@ -279,6 +281,27 @@ _SOURCE_SUMMARY_DETAILS: dict[ReadinessState, str] = {
"not_configured": "No schemas are configured for this source.",
}
+_MAX_NAMED_TABLES = 3
+
+
+def _source_summary_detail(readiness_state: ReadinessState, rows: list[SourceTableStatus]) -> str:
+ attention = [row for row in rows if row["readiness_state"] == "needs_attention"]
+ failed = [
+ row["table_name"] for row in attention if row["workflow_status"] == ManagedWarehouseSourceJobStatus.FAILED
+ ]
+ if readiness_state != "needs_attention" or not failed or len(failed) != len(attention):
+ return _SOURCE_SUMMARY_DETAILS[readiness_state]
+ names = sorted(failed, key=lambda name: (name.lower(), name))
+ hidden = len(names) - _MAX_NAMED_TABLES
+ if hidden > 0:
+ listed = f"{', '.join(names[:_MAX_NAMED_TABLES])} and {hidden} more"
+ elif len(names) > 1:
+ listed = f"{', '.join(names[:-1])} and {names[-1]}"
+ else:
+ listed = names[0]
+ noun = "table" if len(names) == 1 else "tables"
+ return f"The latest workflow failed for {len(names)} {noun}: {listed}. Select the source for details."
+
def _rollup_sources(tables: list[SourceTableStatus]) -> list[SourceSummary]:
grouped: dict[str, list[SourceTableStatus]] = {}
@@ -298,7 +321,7 @@ def _rollup_sources(tables: list[SourceTableStatus]) -> list[SourceSummary]:
"source_name": rows[0]["source_name"],
"source_type": rows[0]["source_type"],
"readiness_state": readiness_state,
- "detail": _SOURCE_SUMMARY_DETAILS[readiness_state],
+ "detail": _source_summary_detail(readiness_state, rows),
"total_schemas": len(rows),
"applied_schemas": sum(1 for row in rows if row["applied"]),
"last_applied_at": last_applied_at,
diff --git a/products/data_warehouse/backend/tests/test_managed_warehouse_data_status.py b/products/data_warehouse/backend/tests/test_managed_warehouse_data_status.py
index e2a23e3f7f86..bf692bf1ed25 100644
--- a/products/data_warehouse/backend/tests/test_managed_warehouse_data_status.py
+++ b/products/data_warehouse/backend/tests/test_managed_warehouse_data_status.py
@@ -189,6 +189,7 @@ def _table(
applied: bool = True,
last_applied_at: datetime | None = None,
last_synced_at: datetime | None = None,
+ workflow_status: ManagedWarehouseSourceJobStatus = ManagedWarehouseSourceJobStatus.COMPLETED,
) -> SourceTableStatus:
return {
"schema_id": str(uuid4()),
@@ -199,7 +200,7 @@ def _table(
"readiness_state": readiness_state,
"detail": "",
"workflow_type": ManagedWarehouseSourceJobWorkflow.COPY,
- "workflow_status": ManagedWarehouseSourceJobStatus.COMPLETED,
+ "workflow_status": workflow_status,
"workflow_started_at": datetime(2026, 8, 1, tzinfo=UTC),
"applied": applied,
"last_applied_at": last_applied_at,
@@ -291,6 +292,58 @@ class TestRollupSources(SimpleTestCase):
# needs_attention outranks up_to_date, so Postgres sorts first despite the alphabet.
assert [s["source_name"] for s in summaries] == ["Postgres", "Stripe"]
+ @parameterized.expand(
+ [
+ ("one_table", ["orders"], "The latest workflow failed for 1 table: orders. Select the source for details."),
+ (
+ "two_tables",
+ ["refunds", "orders"],
+ "The latest workflow failed for 2 tables: orders and refunds. Select the source for details.",
+ ),
+ (
+ "exactly_as_many_as_fit",
+ ["refunds", "orders", "charges"],
+ "The latest workflow failed for 3 tables: charges, orders and refunds. Select the source for details.",
+ ),
+ (
+ "more_than_fit",
+ ["refunds", "orders", "Invoices", "charges", "payouts"],
+ "The latest workflow failed for 5 tables: charges, Invoices, orders and 2 more. Select the source for details.",
+ ),
+ (
+ "attention_without_a_failed_workflow",
+ ["orders"],
+ "One or more schemas need attention.",
+ ManagedWarehouseSourceJobStatus.RUNNING,
+ ),
+ ]
+ )
+ def test_needs_attention_detail_names_the_failing_tables(
+ self,
+ _name: str,
+ failing_tables: list[str],
+ expected_detail: str,
+ workflow_status: ManagedWarehouseSourceJobStatus = ManagedWarehouseSourceJobStatus.FAILED,
+ ) -> None:
+ source_id = str(uuid4())
+ tables = [
+ _table(
+ source_id=source_id,
+ source_name="Stripe",
+ table_name=name,
+ readiness_state="needs_attention",
+ workflow_status=workflow_status,
+ )
+ for name in failing_tables
+ ]
+ tables.append(
+ _table(source_id=source_id, source_name="Stripe", table_name="customers", readiness_state="up_to_date")
+ )
+
+ [summary] = _rollup_sources(tables)
+
+ assert summary["detail"] == expected_detail
+
def test_timestamps_roll_up_to_the_most_recent_across_schemas(self) -> None:
# Both event timestamps summarize a source as "the latest time this happened anywhere in
# it"; a min (or a None clobbering the max) would misreport an active source as stale.
diff --git a/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/OverviewTab.tsx b/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/OverviewTab.tsx
index 5c0b66bcecbb..0730ce2dc14b 100644
--- a/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/OverviewTab.tsx
+++ b/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/OverviewTab.tsx
@@ -1,4 +1,5 @@
import { useActions, useValues } from 'kea'
+import posthog from 'posthog-js'
import { IconDatabase, IconPeople, IconRefresh } from '@posthog/icons'
@@ -7,6 +8,7 @@ import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonCard } from 'lib/lemon-ui/LemonCard'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'
+import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
import { Link } from 'lib/lemon-ui/Link'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { humanFriendlyDetailedTime } from 'lib/utils/datetime'
@@ -81,15 +83,33 @@ export function OverviewTab(): JSX.Element {
const { loadManagedWarehouseDataStatus } = useActions(managedWarehouseDataStatusLogic)
const { loadSourceSchemas } = useActions(sourceSchemasModalLogic)
+ const openSourceSchemas = (source: ManagedWarehouseSourceSummaryApi): void => {
+ // pinned: analytics event and property names, renaming breaks dashboards
+ posthog.capture('managed warehouse source schemas opened', {
+ readiness_state: source.readiness_state,
+ source_type: source.source_type,
+ })
+ loadSourceSchemas({ sourceId: source.source_id, sourceName: source.source_name })
+ }
+
const sourceSummaryColumns: LemonTableColumns<ManagedWarehouseSourceSummaryApi> = [
{
title: 'Source',
key: 'source',
render: (_, source) => (
- <div>
- <div className="font-medium">{source.source_name}</div>
- <div className="text-xs text-muted">{source.source_type}</div>
- </div>
+ <LemonTableLink
+ title={source.source_name}
+ description={source.source_type}
+ to={urls.dataWarehouseSource(`managed-${source.source_id}`, 'schemas')}
+ data-attr="managed-warehouse-source-schemas"
+ onClick={(e) => {
+ // A plain click opens the table list. Cmd or Ctrl-click skips this handler
+ // and opens the source page in a new tab.
+ e.preventDefault()
+ e.stopPropagation()
+ openSourceSchemas(source)
+ }}
+ />
),
sorter: (a, b) => a.source_name.localeCompare(b.source_name),
},
@@ -99,7 +119,7 @@ export function OverviewTab(): JSX.Element {
render: (_, source) => (
<div className="space-y-1 max-w-96">
<StatusTag readinessState={source.readiness_state} />
- <div className="text-xs text-muted">{source.detail}</div>
+ <div className="text-xs text-muted break-words">{source.detail}</div>
</div>
),
sorter: (a, b) => STATUS_SEVERITY[a.readiness_state] - STATUS_SEVERITY[b.readiness_state],
@@ -207,7 +227,7 @@ export function OverviewTab(): JSX.Element {
<div>
<h3 className="mb-1">Imported source tables</h3>
<p className="text-xs text-muted mb-0">
- Reflects the warehouse source imports currently enabled to sync.{' '}
+ Shows your warehouse source imports, including tables with sync paused.{' '}
<Link to={urls.sources()}>Manage sources</Link>
</p>
</div>
@@ -221,8 +241,7 @@ export function OverviewTab(): JSX.Element {
rowKey="source_id"
pagination={{ pageSize: 20 }}
onRow={(source) => ({
- onClick: () =>
- loadSourceSchemas({ sourceId: source.source_id, sourceName: source.source_name }),
+ onClick: () => openSourceSchemas(source),
className: 'cursor-pointer',
})}
/>
diff --git a/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/SourceSchemasModal.tsx b/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/SourceSchemasModal.tsx
index be7737ccab1a..9d4fdb240ec8 100644
--- a/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/SourceSchemasModal.tsx
+++ b/products/data_warehouse/frontend/scenes/DataOpsScene/tabs/SourceSchemasModal.tsx
@@ -1,4 +1,5 @@
import { useActions, useValues } from 'kea'
+import posthog from 'posthog-js'
import { IconRefresh } from '@posthog/icons'
@@ -6,6 +7,7 @@ import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { LemonTable } from 'lib/lemon-ui/LemonTable'
+import { urls } from 'scenes/urls'
import { sourceSchemasModalLogic } from './sourceSchemasModalLogic'
import { sourceSchemaColumns } from './warehouseStatusDisplay'
@@ -20,6 +22,22 @@ export function SourceSchemasModal(): JSX.Element {
onClose={closeSourceSchemasModal}
title={activeSource ? `${activeSource.sourceName} schemas` : 'Schemas'}
width={960}
+ footer={
+ activeSource ? (
+ <LemonButton
+ type="secondary"
+ to={urls.dataWarehouseSource(`managed-${activeSource.sourceId}`, 'schemas')}
+ data-attr="managed-warehouse-source-schemas-manage-source"
+ onClick={() => {
+ // pinned: analytics event name, renaming breaks dashboards
+ posthog.capture('managed warehouse source opened from schemas')
+ closeSourceSchemasModal()
+ }}
+ >
+ Manage source
+ </LemonButton>
+ ) : null
+ }
>
{sourceSchemasError ? (
<LemonBanner type="error">