From 3cea9204cfd780aacaa3f070f7210a1f84f45596 Mon Sep 17 00:00:00 2001 From: Thomas Draier Date: Wed, 18 Dec 2024 16:10:39 +0100 Subject: [PATCH] [front] Enforce unique name for data source (#9497) --- front/lib/api/data_sources.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/front/lib/api/data_sources.ts b/front/lib/api/data_sources.ts index 597aba0c83b8..847f6b5b5344 100644 --- a/front/lib/api/data_sources.ts +++ b/front/lib/api/data_sources.ts @@ -823,6 +823,14 @@ export async function createDataSourceWithoutProvider( }); } + if (dataSources.some((ds) => ds.name === name)) { + return new Err({ + name: "dust_error", + code: "invalid_request_error", + message: "Data source with that name already exist.", + }); + } + const dataSourceEmbedder = owner.defaultEmbeddingProvider ?? DEFAULT_EMBEDDING_PROVIDER_ID; const embedderConfig = EMBEDDING_CONFIGS[dataSourceEmbedder];