Fix/backup restore with invalid settings (#1793)

* Fix typo in setting validation error message

* Convert value to internal type before validating it

* Only update setting in case value is valid

* Ignore settings validation errors on backup restore

* Remove potential not privacy safe value from logs
This commit is contained in:
schroda
2025-11-26 03:56:57 +01:00
committed by GitHub
parent b58a716daa
commit aa8d27f679
4 changed files with 30 additions and 11 deletions
@@ -109,7 +109,7 @@ open class SettingDelegate<T : Any>(
val error = validate(initialValue)
if (error != null) {
KotlinLogging.logger { }.warn {
"Invalid config value ($initialValue) for $moduleName.$propertyName: $error. Using default value: $defaultValue"
"Invalid config value for $moduleName.$propertyName: $error. Using default value: $defaultValue"
}
stateFlow.value = toValidValue?.let { it(initialValue) } ?: defaultValue
@@ -406,8 +406,8 @@ class DisableableDoubleSetting(
validator = { value ->
when {
value == 0.0 -> null
min != null && value < min -> "Value must 0.0 or be at least $min"
max != null && value > max -> "Value must 0.0 or not exceed $max"
min != null && value < min -> "Value must be 0.0 or be at least $min"
max != null && value > max -> "Value must be 0.0 or not exceed $max"
else -> null
}
},