: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): show schema label instead of raw id in sync failure digest (#65438)
Marcus Hof852a617f2d62
diff --git a/products/data_warehouse/backend/external_data_source/notifications.py b/products/data_warehouse/backend/external_data_source/notifications.pyindex 6cf4b2e6dd91..5bdc15b9218f 100644--- a/products/data_warehouse/backend/external_data_source/notifications.py+++ b/products/data_warehouse/backend/external_data_source/notifications.py@@ -92,7 +92,9 @@ def notify_external_data_sync_failures(team_id: int) -> None:)items.append({- "schema_name": schema.name,+ # Prefer the human-readable label (e.g. a Slack channel name) over the+ # raw identifier in `name` (e.g. a Slack channel id); fall back to name.+ "schema_name": schema.label or schema.name,"source_id": str(schema.source_id),"source_type": schema.source.source_type,"source_prefix": (schema.source.prefix or "").rstrip("_"),diff --git a/products/data_warehouse/backend/external_data_source/test/test_notifications.py b/products/data_warehouse/backend/external_data_source/test/test_notifications.pyindex fc243ca822e0..e1ac2032b23b 100644--- a/products/data_warehouse/backend/external_data_source/test/test_notifications.py+++ b/products/data_warehouse/backend/external_data_source/test/test_notifications.py@@ -1,5 +1,6 @@import uuidimport datetime as dt+from urllib.parse import quoteimport pytestfrom unittest.mock import patch@@ -70,6 +71,33 @@ class TestNotifyExternalDataSyncFailures:assert items[0]["source_type"] == "Stripe"assert f"managed-{source.id}/syncs?schema=Invoice" in items[0]["url"]+ @pytest.mark.parametrize(+ "name,label,expected_display",+ [+ ("C08LGV7UHS9", "#data-alerts", "#data-alerts"), # label preferred for display+ ("Charge", None, "Charge"), # falls back to name when label is missing+ ],+ )+ def test_display_uses_label_but_url_uses_name(self, name, label, expected_display):+ team, source = _create_team_and_source()+ ExternalDataSchema.objects.create(+ name=name,+ label=label,+ team=team,+ source=source,+ status=ExternalDataSchema.Status.FAILED,+ latest_error="transient error",+ )++ with patch(SENDER_PATH) as mock_sender:+ notify_external_data_sync_failures(team.pk)++ (_, items) = mock_sender.call_args.args+ # The displayed name prefers the human-readable label...+ assert items[0]["schema_name"] == expected_display+ # ...but the deep link always keeps using the raw identifier.+ assert f"?schema={quote(name)}" in items[0]["url"]+@pytest.mark.parametrize("status,should_sync,deleted",[