Skip to content

Commit

Permalink
Panic and don't display dangling website if any on website list (#7369)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph authored Sep 13, 2024
1 parent f7b58a3 commit 02e1e40
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions front/pages/w/[wId]/builder/data-sources/public-urls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 = {
Expand Down Expand Up @@ -96,30 +96,30 @@ 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,
connector,
};
});

const dataSources = removeNulls(dataSourcesWithConnector);

return {
props: {
owner,
Expand Down

0 comments on commit 02e1e40

Please sign in to comment.