From b6175ef1a77e3acdac7f561cb0f6c05cee7aade4 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:52:13 +0100 Subject: [PATCH] fix: importing chats from Settings does nothing when the file is not valid JSON or the import fails (#35269) Settings > Data Controls > Import Chats did nothing at all for a file that is not valid JSON, and also when the server refused the import. A file that is not valid JSON now shows "Invalid file format.", the same message the sidebar import uses, and a failed import shows its error. Fixes #35268 --- src/lib/components/chat/Settings/DataControls.svelte | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/Settings/DataControls.svelte b/src/lib/components/chat/Settings/DataControls.svelte index 1703c1e198..504e38c653 100644 --- a/src/lib/components/chat/Settings/DataControls.svelte +++ b/src/lib/components/chat/Settings/DataControls.svelte @@ -38,7 +38,13 @@ let reader = new FileReader(); reader.onload = (event) => { - let chats = JSON.parse(event.target.result); + let chats; + try { + chats = JSON.parse(event.target.result); + } catch { + toast.error($i18n.t('Invalid file format.')); + return; + } console.log(chats); if (getImportOrigin(chats) == 'openai') { try { @@ -82,7 +88,9 @@ }; } }) - ); + ).catch((error) => { + toast.error(`${error}`); + }); if (res) { toast.success(`Successfully imported ${res.length} chats.`); }