diff --git a/CHANGELOG.md b/CHANGELOG.md index 280e9fa7..f4bb5060 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ changes you may need to make. - **BREAKING**: Minimum required Sonarr version increased to `3.0.9.1549` (Previous minimum version was `3.0.4.1098`). +- **BREAKING**: Old boolean syntax for `reset_unmatched_scores` is no longer supported. ## [5.4.3] - 2023-09-16 diff --git a/src/Recyclarr.TrashLib.Config/Parsing/ConfigParser.cs b/src/Recyclarr.TrashLib.Config/Parsing/ConfigParser.cs index c5707d38..ba027667 100644 --- a/src/Recyclarr.TrashLib.Config/Parsing/ConfigParser.cs +++ b/src/Recyclarr.TrashLib.Config/Parsing/ConfigParser.cs @@ -47,18 +47,25 @@ public class ConfigParser _log.Debug(e, "Exception while parsing config file"); var line = e.Start.Line; - switch (e.InnerException) + + var contextualMsg = ConfigContextualMessages.GetContextualErrorFromException(e); + if (contextualMsg is not null) + { + _log.Error("Exception at line {Line}: {Msg}", line, contextualMsg); + } + else { - case InvalidCastException: - _log.Error("Incompatible value assigned/used at line {Line}: {Msg}", line, - e.InnerException.Message); - break; + switch (e.InnerException) + { + case InvalidCastException: + _log.Error("Incompatible value assigned/used at line {Line}: {Msg}", line, + e.InnerException.Message); + break; - default: - var msg = ConfigContextualMessages.GetContextualErrorFromException(e) ?? - e.InnerException?.Message ?? e.Message; - _log.Error("Exception at line {Line}: {Msg}", line, msg); - break; + default: + _log.Error("Exception at line {Line}: {Msg}", line, e.InnerException?.Message ?? e.Message); + break; + } } } diff --git a/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjects.cs b/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjects.cs index 9689e699..26a2c9e8 100644 --- a/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjects.cs +++ b/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjects.cs @@ -1,7 +1,5 @@ -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; -using Recyclarr.TrashLib.Config.Parsing.BackwardCompatibility; using Recyclarr.TrashLib.Config.Parsing.PostProcessing.ConfigMerging; using YamlDotNet.Serialization; @@ -45,13 +43,8 @@ public record QualityProfileQualityConfigYaml } [UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] -[TypeConverter(typeof(ResetUnmatchedScoresYamlTypeConverter))] public record ResetUnmatchedScoresConfigYaml { - // This exists so that we know if this value came from the legacy 'true|false' value. - [YamlIgnore] - public bool FromBool { get; set; } - public bool? Enabled { get; init; } public IReadOnlyCollection? Except { get; init; } } diff --git a/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjectsValidation.cs b/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjectsValidation.cs index 74e64345..70bba0c3 100644 --- a/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjectsValidation.cs +++ b/src/Recyclarr.TrashLib.Config/Parsing/ConfigYamlDataObjectsValidation.cs @@ -93,13 +93,6 @@ public class ResetUnmatchedScoresConfigYamlValidator : AbstractValidator x.Enabled) .NotNull() .WithMessage("Under `reset_unmatched_scores`, the `enabled` property is required."); - - RuleFor(x => x.FromBool) - .Must(x => !x) // must be false - .WithMessage( - "Using true/false with `reset_unmatched_scores` is deprecated. " + - "See: https://recyclarr.dev/wiki/upgrade-guide/v6.0/#reset-scores") - .WithSeverity(Severity.Warning); } } diff --git a/src/Recyclarr.TrashLib.Config/Parsing/ErrorHandling/ConfigContextualMessages.cs b/src/Recyclarr.TrashLib.Config/Parsing/ErrorHandling/ConfigContextualMessages.cs index d06557ab..969a3558 100644 --- a/src/Recyclarr.TrashLib.Config/Parsing/ErrorHandling/ConfigContextualMessages.cs +++ b/src/Recyclarr.TrashLib.Config/Parsing/ErrorHandling/ConfigContextualMessages.cs @@ -6,7 +6,17 @@ public static class ConfigContextualMessages { public static string? GetContextualErrorFromException(YamlException e) { - if (e.Message.Contains( + return LookupMessage(e.Message) ?? LookupMessage(e.InnerException?.Message); + } + + private static string? LookupMessage(string? msg) + { + if (msg is null) + { + return null; + } + + if (msg.Contains( "Property 'reset_unmatched_scores' not found on type " + $"'{typeof(QualityScoreConfigYaml).FullName}'")) { @@ -16,6 +26,14 @@ public static class ConfigContextualMessages "See: https://recyclarr.dev/wiki/upgrade-guide/v5.0/#reset-unmatched-scores"; } + if (msg.Contains( + $"Invalid cast from 'System.String' to '{typeof(ResetUnmatchedScoresConfigYaml).FullName}'")) + { + return + "Using true/false with `reset_unmatched_scores` is no longer supported. " + + "See: https://recyclarr.dev/wiki/upgrade-guide/v6.0/#reset-scores"; + } + return null; } } diff --git a/src/Recyclarr.TrashLib/Settings/SettingsContextualMessages.cs b/src/Recyclarr.TrashLib/Settings/SettingsContextualMessages.cs index aa17ed1d..d76fab50 100644 --- a/src/Recyclarr.TrashLib/Settings/SettingsContextualMessages.cs +++ b/src/Recyclarr.TrashLib/Settings/SettingsContextualMessages.cs @@ -6,7 +6,17 @@ public static class SettingsContextualMessages { public static string? GetContextualErrorFromException(YamlException e) { - if (e.Message.Contains( + return LookupMessage(e.Message) ?? LookupMessage(e.InnerException?.Message); + } + + private static string? LookupMessage(string? msg) + { + if (msg is null) + { + return null; + } + + if (msg.Contains( "Property 'repository' not found on type " + $"'{typeof(SettingsValues).FullName}'")) { diff --git a/src/Recyclarr.TrashLib/Settings/SettingsProvider.cs b/src/Recyclarr.TrashLib/Settings/SettingsProvider.cs index 30431d76..badc0347 100644 --- a/src/Recyclarr.TrashLib/Settings/SettingsProvider.cs +++ b/src/Recyclarr.TrashLib/Settings/SettingsProvider.cs @@ -40,7 +40,7 @@ public class SettingsProvider : ISettingsProvider _log.Debug(e, "Exception while parsing settings file"); var line = e.Start.Line; - var msg = SettingsContextualMessages.GetContextualErrorFromException(e); + var msg = SettingsContextualMessages.GetContextualErrorFromException(e) ?? e.Message; _log.Error("Exception while parsing settings.yml at line {Line}: {Msg}", line, msg); throw;