fix(fireflyiii): respect user-configured DB credentials when using mariadb_addon

When DB_CONNECTION is set to mariadb_addon, the script now checks if the user
has explicitly configured DB_USERNAME, DB_PASSWORD, or DB_DATABASE in addon
options. If set, those values are used instead of the MariaDB addon service
discovery credentials. This fixes authentication failures when the service
account doesn't have proper access.

Fixes: Firefly III access denied for user 'service' issue

Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/7cacda5b-d03e-47c5-b4fc-4cfb4ef2a3dc

Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-20 09:09:20 +00:00
committed by GitHub
parent f607a1a0d6
commit 547f1214b4
3 changed files with 25 additions and 7 deletions

View File

@@ -90,9 +90,26 @@ case $(bashio::config 'DB_CONNECTION') in
DB_CONNECTION=mysql
DB_HOST=$(bashio::services "mysql" "host")
DB_PORT=$(bashio::services "mysql" "port")
DB_DATABASE=firefly
DB_USERNAME=$(bashio::services "mysql" "username")
DB_PASSWORD=$(bashio::services "mysql" "password")
# Use user-configured database name if provided, otherwise default to 'firefly'
if bashio::config.has_value "DB_DATABASE"; then
DB_DATABASE=$(bashio::config "DB_DATABASE")
else
DB_DATABASE=firefly
fi
# Use user-configured credentials if provided, otherwise use service discovery
if bashio::config.has_value "DB_USERNAME"; then
DB_USERNAME=$(bashio::config "DB_USERNAME")
else
DB_USERNAME=$(bashio::services "mysql" "username")
fi
if bashio::config.has_value "DB_PASSWORD"; then
DB_PASSWORD=$(bashio::config "DB_PASSWORD")
else
DB_PASSWORD=$(bashio::services "mysql" "password")
fi
export DB_CONNECTION
export DB_HOST && bashio::log.blue "DB_HOST=$DB_HOST"
export DB_PORT && bashio::log.blue "DB_PORT=$DB_PORT"
@@ -110,7 +127,7 @@ case $(bashio::config 'DB_CONNECTION') in
--skip-ssl \
-u "${DB_USERNAME}" -p"${DB_PASSWORD}" \
-h "${DB_HOST}" -P "${DB_PORT}" \
-e "CREATE DATABASE IF NOT EXISTS \`firefly\`;"
-e "CREATE DATABASE IF NOT EXISTS \`${DB_DATABASE}\`;"
;;
# Use remote