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);