From: Marcel van der Veldt Date: Sun, 26 Mar 2023 23:56:19 +0000 (+0200) Subject: config entry wrong value convert X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=0d3c7fb969b1d20b8e7d57cb0a2238e0980b951e;p=music-assistant-server.git config entry wrong value convert --- diff --git a/music_assistant/common/models/config_entries.py b/music_assistant/common/models/config_entries.py index 7013370d..8d5bd57b 100644 --- a/music_assistant/common/models/config_entries.py +++ b/music_assistant/common/models/config_entries.py @@ -215,12 +215,14 @@ class Config(DataClassDictMixin): if update.values is not None: for key, new_val in update.values.items(): cur_val = self.values[key].value - if cur_val == new_val: + # parse entry to do type validation + parsed_val = ConfigEntryValue.parse(self.values[key], new_val) + if cur_val == parsed_val.value: continue - if new_val is None: - self.values[key].value = self.values[key].default_value + if parsed_val.value is None: + self.values[key].value = parsed_val.default_value else: - self.values[key].value = new_val + self.values[key].value = parsed_val.value changed_keys.add(f"values/{key}") return changed_keys diff --git a/music_assistant/server/controllers/config.py b/music_assistant/server/controllers/config.py index 0240f392..1f7c967c 100644 --- a/music_assistant/server/controllers/config.py +++ b/music_assistant/server/controllers/config.py @@ -199,6 +199,10 @@ class ConfigController: """Add new Provider (instance) Config Flow.""" if not config: return await self._get_default_provider_config(provider_domain) + for key, conf_entry_value in config.values.items(): + # parse entry to do type validation + parsed_val = ConfigEntryValue.parse(conf_entry_value, conf_entry_value.value) + conf_entry_value.value = parsed_val.value # if provider config is provided, the frontend wants to submit a new provider instance # based on the earlier created template config. # try to load the provider first to catch errors before we save it.