From 02e1e40babaa2827df50a0760981ed5c92a7b3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daphn=C3=A9=20Popin?= Date: Fri, 13 Sep 2024 11:56:36 +0200 Subject: [PATCH] Panic and don't display dangling website if any on website list (#7369) --- .../[wId]/builder/data-sources/public-urls.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/front/pages/w/[wId]/builder/data-sources/public-urls.tsx b/front/pages/w/[wId]/builder/data-sources/public-urls.tsx index 6d1ad3c39e44..24a5e0850fe7 100644 --- a/front/pages/w/[wId]/builder/data-sources/public-urls.tsx +++ b/front/pages/w/[wId]/builder/data-sources/public-urls.tsx @@ -16,7 +16,7 @@ import type { SubscriptionType, WorkspaceType, } from "@dust-tt/types"; -import { truncate } from "@dust-tt/types"; +import { removeNulls, truncate } from "@dust-tt/types"; import { ConnectorsAPI } from "@dust-tt/types"; import type { InferGetServerSidePropsType } from "next"; import { useRouter } from "next/router"; @@ -37,7 +37,7 @@ import { withDefaultUserAuthRequirements } from "@app/lib/iam/session"; import logger from "@app/logger/logger"; type DataSourceWithConnector = DataSourceType & { - connector: ConnectorType | null; + connector: ConnectorType; }; type Info = { @@ -96,23 +96,21 @@ export const getServerSideProps = withDefaultUserAuthRequirements<{ throw new Error("Failed to fetch connectors"); } - const dataSources = websiteDataSources.map((ds) => { + const dataSourcesWithConnector = websiteDataSources.map((ds) => { const connector = connectorsRes.value.find((c) => c.id === ds.connectorId); if (!connector) { logger.error( { + panic: true, // This is a panic because we want to fix the data. This should never happen. workspaceId: owner.sId, connectorId: ds.connectorId, dataSourceName: ds.name, + dataSourceId: ds.id, connectorProvider: ds.connectorProvider, }, - "Connector not found" + "Connector not found while we still have a data source." ); - // Not super clean but at least we don't crash the page. - return { - ...ds, - connector: null, - }; + return null; } return { ...ds, @@ -120,6 +118,8 @@ export const getServerSideProps = withDefaultUserAuthRequirements<{ }; }); + const dataSources = removeNulls(dataSourcesWithConnector); + return { props: { owner,