YunoHost-Apps / redirect_ynh

Redirection app for YunoHost
GNU Affero General Public License v3.0
44 stars 21 forks source link

reverse-proxy does not install on Yunohost 12 #55

Open anubister opened 6 months ago

anubister commented 6 months ago

Unable to install in mode 'reverse-proxy' on Yunohost 12

It does not install due to "invalid URL" for target parameter (while this parameter is accepted on Yunohost 11).

Context

Steps to reproduce

I tried also: yunohost app install redirect -a "domain=bosh.domain.tld&path=/http-bind&target=http://localhost:5290&redirect_type=reverseproxy" -l BOSH

Expected behavior

As it does on Yunohost 11; goal is to redirect as recommended here : https://forum.yunohost.org/t/unable-to-set-up-bosh-conf-nginx/12995/2

Logs

When command is ran from CLI with --debug:

112  DEBUG   acquiring lock...
121  DEBUG   lock has been acquired
129  DEBUG   loading python module yunohost.app took 0.008s
129  DEBUG   processing action 'yunohost.app.install'
526  DEBUG   Checking default branch
5925 DEBUG   Downloading…
6522 DEBUG   Done
6558 DEBUG   initializing root ldap interface
6559 DEBUG   Checking requirements for redirect…
6565 DEBUG   Checking that required services are up and running...
7522 ERROR   URL host invalid
7522 ERROR   URL host invalid
7522 ERROR   URL host invalid
7522 ERROR   URL host invalid
7523 DEBUG   action executed in 7.393s
7523 DEBUG   lock has been released
7523 ERROR   URL host invalid
anubister commented 6 months ago

The problem seems to come from the new URL validation using pydantic : https://github.com/YunoHost/yunohost/blob/bookworm/src/utils/form.py#L1230C1-L1257C1 ; might be from upstream (Debian 12 is packaging 1.10.4-1 but there is now a v2 which brings deep change (rely on another lib to validate URLs).

In the meantime, I would like to propose to consider URL as a string, applying the previous simple regex validation. Without regex validation it does work, but when trying to apply the regex:

class URLOption(BaseStringOption):
    type: Literal[OptionType.url] = OptionType.string
    pattern = {
        "regexp": r"^https?://.*$",
        "error": "config_validate_url",  # i18n: config_validate_url
    }

I get the following error and not familiar with pydantic: TypeError: The type of URLOption.pattern differs from the new default value; if you wish to change the type of this field, please use a type annotation could anyone provide support?