From 9862584611f29ac3f16e0c6ef0afb183ff3f0588 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 21 Jan 2023 12:54:37 -0600 Subject: [PATCH] Fixed: Catch InvalidDataException during initial config to prevent boot loop --- src/NzbDrone.Host/Bootstrap.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 9e18e262f..55284346a 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -228,11 +228,20 @@ namespace NzbDrone.Host private static IConfiguration GetConfiguration(StartupContext context) { var appFolder = new AppFolderInfo(context); - return new ConfigurationBuilder() - .AddXmlFile(appFolder.GetConfigPath(), optional: true, reloadOnChange: false) - .AddInMemoryCollection(new List> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) }) - .AddEnvironmentVariables() - .Build(); + var configPath = appFolder.GetConfigPath(); + + try + { + return new ConfigurationBuilder() + .AddXmlFile(configPath, optional: true, reloadOnChange: false) + .AddInMemoryCollection(new List> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) }) + .AddEnvironmentVariables() + .Build(); + } + catch (InvalidDataException ex) + { + throw new InvalidConfigFileException($"{configPath} is corrupt or invalid. Please delete the config file and Prowlarr will recreate it.", ex); + } } private static string BuildUrl(string scheme, string bindAddress, int port)