Skip to content

Commit

Permalink
configpanel: raise when unknown filter key
Browse files Browse the repository at this point in the history
  • Loading branch information
Axolotle committed Nov 26, 2023
1 parent 25e23ce commit d28b6e9
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/utils/configpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

if TYPE_CHECKING:
from moulinette.utils.log import MoulinetteLogger

logger = cast(MoulinetteLogger, getLogger("yunohost.configpanel"))
else:
logger = getLogger("yunohost.configpanel")
Expand Down Expand Up @@ -715,19 +716,26 @@ def filter_keys(
raw_config = self._get_raw_config()

panel_id, section_id, option_id = self.filter_key
if panel_id:
raw_config = filter_keys(raw_config, panel_id, ConfigPanelModel)

if section_id:
raw_config[panel_id] = filter_keys(
raw_config[panel_id], section_id, PanelModel
)
try:
if panel_id:
raw_config = filter_keys(raw_config, panel_id, ConfigPanelModel)

if option_id:
raw_config[panel_id][section_id] = filter_keys(
raw_config[panel_id][section_id], option_id, SectionModel
if section_id:
raw_config[panel_id] = filter_keys(
raw_config[panel_id], section_id, PanelModel
)

if option_id:
raw_config[panel_id][section_id] = filter_keys(
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

def _get_partial_raw_settings_and_mutate_config(
Expand Down

0 comments on commit d28b6e9

Please sign in to comment.