Config Panel seems to be broken for me

I’ve been trying to add a config panel for my app InvoiceNinja5 without success. But everytime I get the error “Config panel question ‘default_from_email’ should be initialized with a value during install or upgrade.” in the frontend.

What I did:

  • Created the config-panel:
version = "1.0"
[main]
	[main.config]
	name = "Configuration"

        [main.config.default_from_email]
        ask = "from email"
        type = "email"
        help = "Default email address to use for various automated emails."
        bind = "default_from_email:__INSTALL_DIR__/.env"

        [main.config.default_from_name]
        ask = "from name"
        type = "name"
        help = "Default name address to use for various automated names."
        bind = "default_from_name:__INSTALL_DIR__/.env"
  • Added the same variables as installation questions:

    [install.default_from_email]
    help.en = "Choose what name will be displayed when InvoiceNinja sends mails."
    help.fr = ""
    type = "email"
    default = ""

    [install.default_from_name]
    help.en = "Choose from which mail-address mails will be send."
    help.fr = ""
    type = "string"
    default = ""
  • Set and use the variables in the installation:
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
ynh_app_setting_set --app="$app" --key=default_from_name --value="$default_from_name"
  • And if there not set, set them during an upgrade:

default_from_email=$(ynh_app_setting_get --app="$app" --key=default_from_email)
if [ -z "$default_from_email" ]; then
	default_from_email="${app}@${domain}"
	ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
fi

default_from_name=$(ynh_app_setting_get --app="$app" --key=default_from_name)
if [ -z "$default_from_name" ]; then
	default_from_name="${app}@${domain}"
	ynh_app_setting_set --app="$app" --key=default_from_name --value="$default_from_name"
fi

The installation (and app itself) works:

sudo yunohost app install ./ -a "domain=foo.example.com&path=/&admin=basti&password=password&language=en" -f
Who should have access to this app? (This can later be changed) [all_users | visitors | admins | talos]: visitors
default_from_email: foo@bar.com
default_from_name: foo bar
Info: Installing invoiceninja5...
Info: Provisioning sources...
Info: Provisioning system_user...
Info: Provisioning install_dir...
Info: Provisioning permissions...
Info: Provisioning apt...
Info: Provisioning database...
Info: [++..................] > Storing secrets to app settings...
Info: [##+++...............] > Setting up source files...
Info: [#####+++............] > Adding system configurations related to invoiceninja5__2...
Info: [########+++.........] > Modifying a config file...
Info: [###########+++......] > Building the application...
Info: [##############+++...] > Adding a cron job...
Info: [#################+++] > Installation of invoiceninja5__2 completed
Success! Installation completed

The settings are also in the settings.yml:

sudo grep "default_from" /etc/yunohost/apps/invoiceninja5__2/settings.yml
default_from_email: foo@bar.com
default_from_name: foo bar

But not the config panel. What am I doing wrong?

The code can be found here: GitHub - YunoHost-Apps/invoiceninja5_ynh at support_mail

The config panel question has

bind = "default_from_email:__INSTALL_DIR__/.env"

so the source of truth is not the yunohost app setting, it’s the content of the .env file, more specifically the key associated to “default_from_email” in that conf file. But as far as I can see, what you really mean is probably MAIL_FROM_ADDRESS instead ?

This is really confusing to me.

When I set this, it still fails with the same error:

        [main.config.MAIL_FROM_ADDRESS]
        ask = "from email"
        type = "email"
        help = "Default email address to use for various automated emails."
        bind = "MAIL_FROM_ADDRESS:__INSTALL_DIR__/.env"

        [main.config.MAIL_FROM_NAME]
        ask = "from name"
        type = "name"
        help = "Default name address to use for various automated names."
        bind = "MAIL_FROM_NAME:__INSTALL_DIR__/.env"

What I basically want to accomplish:

  • The user should on installation set MAIL_FROM_NAME and MAIL_FROM_ADDRESS via parameters in the manifest.toml.
  • The user should be able to change these variables via the config panel. The change needs to be then reflected in the .env file:
MAIL_FROM_ADDRESS='foo@bar.com'
MAIL_FROM_NAME='foo bar'
  • Since I have an existing app, users should be able to change the above parameters in the config panel after they upgraded the app.

Here’s another non-working try: Comparing master...support_mail · YunoHost-Apps/invoiceninja5_ynh · GitHub

try with this:

[main.config.default_from_email]
        ask = "from email"
        type = "email"
        help = "Default email address to use for various automated emails."
        bind = "MAIL_FROM_ADDRESS:__INSTALL_DIR__/.env"

where:
default_from_email in [main.config.default_from_email] is your bash variable
MAIL_FROM_ADDRESS in bind = "MAIL_FROM_ADDRESS:__INSTALL_DIR__/.env" is the key in your config file

I still can’t get it to work. :frowning:

Even if they’re set like this in the config, its not working:

grep -i "MAIL_FROM_ADDRESS" /etc/yunohost/apps/invoiceninja5__2/settings.yml /var/www/invoiceninja5__2/.env
/etc/yunohost/apps/invoiceninja5__2/settings.yml:MAIL_FROM_ADDRESS: INVOICENINJA5__2@INVOICENINJATEST.com
/var/www/invoiceninja5__2/.env:MAIL_FROM_ADDRESS="invoiceninja5__2@invoiceninjatest.com"