From b56ed4c12fae7c503b1a00c2748bd3cdea9da6f9 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:30:16 +1100 Subject: [PATCH] [8.17] [Obs ai assistant] - bug bulk import for knowledge base (#205075) (#205687) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.17`: - [[Obs ai assistant] - bug bulk import for knowledge base (#205075)](https://github.com/elastic/kibana/pull/205075) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Arturo Lidueña --- .../components/knowledge_base_bulk_import_flyout.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx b/x-pack/plugins/observability_solution/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx index 23d5ad00af12a..b1ac694bc9929 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant_management/public/routes/components/knowledge_base_bulk_import_flyout.tsx +++ b/x-pack/plugins/observability_solution/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 (