From 2c97ed3bfec8a99de931d85f50b1e940835bde47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Lidue=C3=B1a?= Date: Tue, 7 Jan 2025 10:44:16 +0100 Subject: [PATCH] [Obs ai assistant] - bug bulk import for knowledge base (#205075) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #196096 ## Summary Wrong successful message with error notification pop up on adding a wrong format file under bulk import for knowledge base [#196096](https://github.com/elastic/kibana/issues/196096) --------- Co-authored-by: Søren Louv-Jansen Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../components/knowledge_base_bulk_import_flyout.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx b/x-pack/solutions/observability/plugins/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx index 23d5ad00af12a..b1ac694bc9929 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx @@ -47,13 +47,18 @@ export function KnowledgeBaseBulkImportFlyout({ onClose }: { onClose: () => void }; const handleSubmitNewEntryClick = async () => { - let entries: Array & { title: string }> = []; const text = await files[0].text(); const elements = text.split('\n').filter(Boolean); try { - entries = elements.map((el) => JSON.parse(el)); + const entries = elements.map( + (el) => + JSON.parse(el) as Omit & { + title: string; + } + ); + await mutateAsync({ entries }); } catch (_) { toasts.addError( new Error( @@ -74,8 +79,7 @@ export function KnowledgeBaseBulkImportFlyout({ onClose }: { onClose: () => void } ); } - - mutateAsync({ entries }).then(onClose); + onClose(); }; return (