configpanel: raise when unknown filter key

This commit is contained in:
axolotle 2023-11-26 17:01:38 +01:00
parent 25e23ce963
commit d28b6e96c8

View file

@ -53,6 +53,7 @@ if TYPE_CHECKING:
if TYPE_CHECKING: if TYPE_CHECKING:
from moulinette.utils.log import MoulinetteLogger from moulinette.utils.log import MoulinetteLogger
logger = cast(MoulinetteLogger, getLogger("yunohost.configpanel")) logger = cast(MoulinetteLogger, getLogger("yunohost.configpanel"))
else: else:
logger = getLogger("yunohost.configpanel") logger = getLogger("yunohost.configpanel")
@ -715,6 +716,8 @@ class ConfigPanel:
raw_config = self._get_raw_config() raw_config = self._get_raw_config()
panel_id, section_id, option_id = self.filter_key panel_id, section_id, option_id = self.filter_key
try:
if panel_id: if panel_id:
raw_config = filter_keys(raw_config, panel_id, ConfigPanelModel) raw_config = filter_keys(raw_config, panel_id, ConfigPanelModel)
@ -727,6 +730,11 @@ class ConfigPanel:
raw_config[panel_id][section_id] = filter_keys( raw_config[panel_id][section_id] = filter_keys(
raw_config[panel_id][section_id], option_id, SectionModel raw_config[panel_id][section_id], option_id, SectionModel
) )
except KeyError:
raise YunohostValidationError(
"config_unknown_filter_key",
filter_key=".".join([k for k in self.filter_key if k]),
)
return raw_config return raw_config