From 947b1f217a24aebd404a6d0810e798be84f32018 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 14 Feb 2025 12:16:10 +0100 Subject: [PATCH] Added handling for default providers --- .../Tools/Services/DataSourceService.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/MindWork AI Studio/Tools/Services/DataSourceService.cs b/app/MindWork AI Studio/Tools/Services/DataSourceService.cs index 151be631..43c44b02 100644 --- a/app/MindWork AI Studio/Tools/Services/DataSourceService.cs +++ b/app/MindWork AI Studio/Tools/Services/DataSourceService.cs @@ -30,6 +30,17 @@ public sealed class DataSourceService /// The allowed data sources and the data sources selected before -- when they are still allowed. public async Task GetDataSources(AIStudio.Settings.Provider selectedLLMProvider, IReadOnlyCollection? previousSelectedDataSources = null) { + // + // Case: Somehow the selected LLM provider was not set. The default provider + // does not mean anything. We cannot filter the data sources by any means. + // We return an empty list. Better safe than sorry. + // + if (selectedLLMProvider == default) + { + this.logger.LogWarning("The selected LLM provider is not set. We cannot filter the data sources by any means."); + return new([], []); + } + var allDataSources = this.settingsManager.ConfigurationData.DataSources; var filteredDataSources = new List(allDataSources.Count); var filteredSelectedDataSources = new List(previousSelectedDataSources?.Count ?? 0);