YunoHost / issues

General issue tracker for the YunoHost project
72 stars 8 forks source link

KeyError: 'security_experimental_enabled' when updating Yunohost setting in webadmin #2476

Open SohKa opened 2 weeks ago

SohKa commented 2 weeks ago

Describe the bug

In the Yunohost webadmin, under "Tools > YunoHost settings > Other", when I try to change setting IP versions to consider for DNS configuration and diagnosis from Both to IPv4 only, I get a 500 Unexpected server error.

Via CLI, it works as expected.

Context

To reproduce

========================================

Other

Network

Info: Saving the new configuration... Success! Config updated as expected


### Logs

No logs in "Tools > Logs", so I must paste the stacktrace here, sorry.

Error: "500" Action: "PUT" /yunohost/api/settings/misc Error message: Unexpected server error Traceback (most recent call last): File "/usr/lib/python3/dist-packages/moulinette/interfaces/api.py", line 473, in process ret = self.actionsmap.process(arguments, timeout=30, route=_route) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/moulinette/actionsmap.py", line 561, in process return func(*arguments) ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/log.py", line 480, in func_wrapper result = func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/settings.py", line 102, in settings_set return settings.set(key, value, args, args_file, operation_logger=operation_logger) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/utils/configpanel.py", line 577, in set self.form = self._ask( ^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/utils/configpanel.py", line 855, in _ask ) or not section.is_visible(context): ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/utils/configpanel.py", line 169, in is_visible return evaluate_simple_js_expression(self.visible, context=context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/utils/form.py", line 216, in evaluate_simple_js_expression return evaluate_simple_ast(node, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/yunohost/utils/form.py", line 104, in evaluate_simple_ast return context[node.id]


KeyError: 'security_experimental_enabled'
```
To be complete, here is a screenshot of the issue:
![image](https://github.com/user-attachments/assets/1150f8ab-d806-497d-bd73-15da677a1705)
Axolotle commented 1 week ago

Hum, I can't reproduce this error, but there's indeed a visible prop on a section in the misc tab:

[misc.tls_passthrough]
visible = "security_experimental_enabled"

        [misc.tls_passthrough.tls_passthrough_enabled]
        type = "boolean"
        default = false

        [misc.tls_passthrough.tls_passthrough_explain]
        type = "alert"
        style = "info"
        icon = "info"
        visible = "tls_passthrough_enabled"

        [misc.tls_passthrough.tls_passthrough_list]
        type = "tags"
        # Regex is just <domain regex>;<destination>;<port>
        pattern.regexp = '^(([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+((xn--)?[^\W_]{2,}));(([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+((xn--)?([^\W_]{2,}|[0-9]{1,3})));[0-9]{1,}$'
        pattern.error = "You should specify a list of items formatted as DOMAIN;DESTINATION;DESTPORT, such as yolo.test;192.168.1.42;443"
        default = ""
        visible = "tls_passthrough_enabled"

We chose to not pass other panel's settings in context so this is expected to not work. Should we move this section to the security tab?