diff --git a/front/lib/api/data_sources.ts b/front/lib/api/data_sources.ts index b8188e5958ba..eadba5211d05 100644 --- a/front/lib/api/data_sources.ts +++ b/front/lib/api/data_sources.ts @@ -195,12 +195,11 @@ export async function deleteDataSource( const dustAPIProjectId = dataSource.dustAPIProjectId; - if ( - dataSource.connectorId && - dataSource.connectorProvider && - !MANAGED_DS_DELETABLE_AS_BUILDER.includes(dataSource.connectorProvider) - ) { - if (!auth.isAdmin()) { + if (dataSource.connectorId && dataSource.connectorProvider) { + if ( + !MANAGED_DS_DELETABLE_AS_BUILDER.includes(dataSource.connectorProvider) && + !auth.isAdmin() + ) { return new Err({ type: "workspace_auth_error", message: diff --git a/front/pages/api/w/[wId]/data_sources/[name]/index.ts b/front/pages/api/w/[wId]/data_sources/[name]/index.ts index 477ac4adef59..354799a843f9 100644 --- a/front/pages/api/w/[wId]/data_sources/[name]/index.ts +++ b/front/pages/api/w/[wId]/data_sources/[name]/index.ts @@ -1,5 +1,4 @@ import type { DataSourceType, WithAPIErrorReponse } from "@dust-tt/types"; -import { ConnectorsAPI } from "@dust-tt/types"; import type { NextApiRequest, NextApiResponse } from "next"; import { @@ -9,7 +8,6 @@ import { } from "@app/lib/api/data_sources"; import { Authenticator, getSession } from "@app/lib/auth"; import { DataSource } from "@app/lib/models"; -import logger from "@app/logger/logger"; import { apiError, withLogging } from "@app/logger/withlogging"; export type GetOrPostDataSourceResponseBody = { @@ -174,7 +172,7 @@ async function handler( }); } - // We only expose deleted non-managed data sources. + // We only allow deleteing selected managed data sources as builder. if ( dataSource.connectorId && dataSource.connectorProvider && @@ -189,27 +187,6 @@ async function handler( }); } - if (dataSource.connectorId && !dataSource.connectorProvider) { - const connectorsAPI = new ConnectorsAPI(logger); - const deleteRes = await connectorsAPI.deleteConnector( - dataSource.connectorId - ); - if (deleteRes.isErr()) { - return apiError( - req, - res, - { - status_code: 500, - api_error: { - type: "internal_server_error", - message: deleteRes.error.message, - }, - }, - new Error(deleteRes.error.message) - ); - } - } - const dRes = await deleteDataSource(auth, dataSource.name); if (dRes.isErr()) { return apiError(req, res, {