From 3b67bef37310ee483b35f3ff34ced8cd3045b124 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Jul 2026 17:46:30 +0200 Subject: [PATCH 1/2] Fix Bazarr base_url sed clobbering Radarr/Sonarr's own base_url Bazarr's config.yaml carries a base_url key under general: (Bazarr's own ingress path) AND a separate base_url under each configured *arr integration -- radarr.base_url, sonarr.base_url, etc. -- which is how Bazarr reaches those services at their own ingress-prefixed URL. Every base_url sed in this addon was unscoped: sed -i "s| base_url:.*| base_url: /$slug|" "$CONFIG_LOCATION" sed applies s/// to every matching line in the file, not just the first, and " base_url:.*" matches any 2-space-indented base_url line regardless of which top-level section it's under. Since general.base_url, radarr.base_url, sonarr.base_url etc. all sit at that same indent, this rewrote all of them to Bazarr's own value on every container start (32-nginx_ingress.sh) and again in the run script's fallback -- silently breaking Bazarr's configured connections to Radarr and Sonarr. Scope each sed to the general: block only, reusing the range idiom this file already uses to scope the auth: block's type: substitution: sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" ... Verified against a representative config.yaml (general/radarr/sonarr/subsarr sections, including general:'s list-style provider entries) for all three connection_mode branches plus the run script's fallback: general.base_url is the only line touched in every case; radarr.base_url and sonarr.base_url survive with their original values. Co-Authored-By: Claude Opus 5 --- bazarr/CHANGELOG.md | 4 ++++ bazarr/config.yaml | 2 +- bazarr/rootfs/etc/cont-init.d/32-nginx_ingress.sh | 15 ++++++++++----- bazarr/rootfs/etc/services.d/nginx/run | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bazarr/CHANGELOG.md b/bazarr/CHANGELOG.md index 10249b94b1..f9b1dee8e2 100644 --- a/bazarr/CHANGELOG.md +++ b/bazarr/CHANGELOG.md @@ -1,4 +1,8 @@ +## 1.6.0.2 (2026-07-27) + +- Fix base_url sed patterns rewriting *every* `base_url` key in Bazarr's config.yaml (radarr.base_url, sonarr.base_url, and any other configured integration), instead of only Bazarr's own under `general:`. This silently broke the Radarr/Sonarr connections inside Bazarr on every addon restart when ingress was enabled + ## 1.6.0.1 (2026-07-27) - Fix ingress: nginx rewrote Bazarr's redirects into an absolute `http://:8099/...` URL, which the browser blocked as mixed content when Home Assistant is served over HTTPS. Redirects now stay relative and point at the ingress path diff --git a/bazarr/config.yaml b/bazarr/config.yaml index 0ad56e4885..31d9cb7bbb 100644 --- a/bazarr/config.yaml +++ b/bazarr/config.yaml @@ -112,4 +112,4 @@ schema: slug: bazarr_nas udev: true url: https://github.com/alexbelgium/hassio-addons/tree/master/bazarr -version: "1.6.0.1" +version: "1.6.0.2" diff --git a/bazarr/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/bazarr/rootfs/etc/cont-init.d/32-nginx_ingress.sh index 56df012b68..0db15509ee 100755 --- a/bazarr/rootfs/etc/cont-init.d/32-nginx_ingress.sh +++ b/bazarr/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -35,16 +35,20 @@ if [ -f "$CONFIG_LOCATION" ]; then ingress_noauth) bashio::log.green "Ingress is enabled, authentication is disabled" bashio::log.yellow "WARNING : Make sure that the port is not exposed externally by your router to avoid a security risk !" - # Set base_url (must start with / for Flask blueprint registration) - sed -i "s| base_url:.*| base_url: /$slug|" "$CONFIG_LOCATION" + # Set base_url (must start with / for Flask blueprint registration). + # Scoped to the general: block only -- config.yaml also carries a + # base_url under each configured *arr integration (radarr.base_url, + # sonarr.base_url, ...) and those must not be touched. + sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" "$CONFIG_LOCATION" # Disable auth sed -i '/^auth:/,/^[^ ]/{ s/ type:.*/ type: null/ }' "$CONFIG_LOCATION" ;; # Ingress mode, with authentication ingress_auth) bashio::log.green "Ingress is enabled, and external authentication is enabled" - # Set base_url (must start with / for Flask blueprint registration) - sed -i "s| base_url:.*| base_url: /$slug|" "$CONFIG_LOCATION" + # Set base_url (must start with / for Flask blueprint registration). + # Scoped to the general: block only -- see note above. + sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" "$CONFIG_LOCATION" # Enable Bazarr auth when leaving ingress_noauth sed -i '/^auth:/,/^[^ ]/{ s/ type:.*/ type: form/ }' "$CONFIG_LOCATION" ;; @@ -52,7 +56,8 @@ if [ -f "$CONFIG_LOCATION" ]; then noingress_auth) bashio::log.green "Disabling ingress and enabling authentication" bashio::log.yellow "WARNING : Ingress is disabled so the app won't be available from HA itself !" - sed -i "s/ base_url:.*/ base_url: ''/" "$CONFIG_LOCATION" + # Scoped to the general: block only -- see note above. + sed -i "/^general:/,/^[^ ]/{ s/ base_url:.*/ base_url: ''/; }" "$CONFIG_LOCATION" # Enable Bazarr auth when leaving ingress_noauth sed -i '/^auth:/,/^[^ ]/{ s/ type:.*/ type: form/ }' "$CONFIG_LOCATION" ;; diff --git a/bazarr/rootfs/etc/services.d/nginx/run b/bazarr/rootfs/etc/services.d/nginx/run index daf1d3739b..59d20fe581 100644 --- a/bazarr/rootfs/etc/services.d/nginx/run +++ b/bazarr/rootfs/etc/services.d/nginx/run @@ -17,8 +17,11 @@ if [ -f "$CONFIG_LOCATION" ]; then if ! bashio::config.has_value "connection_mode" || [ "$(bashio::config 'connection_mode')" != "noingress_auth" ]; then if ! grep -q "base_url: /$slug" "$CONFIG_LOCATION"; then bashio::log.warning "BaseUrl not set properly, restarting" - # Must start with / for Flask blueprint registration - sed -i "s| base_url:.*| base_url: /$slug|" "$CONFIG_LOCATION" + # Must start with / for Flask blueprint registration. Scoped to + # the general: block only -- config.yaml also carries a base_url + # under each configured *arr integration (radarr.base_url, + # sonarr.base_url, ...) and those must not be touched. + sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" "$CONFIG_LOCATION" bashio::addon.restart fi fi From 16931942b964597546ae377612c6137d53b38390 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 27 Jul 2026 19:41:16 +0200 Subject: [PATCH 2/2] Fix Bazarr base_url guard scope --- bazarr/rootfs/etc/services.d/nginx/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr/rootfs/etc/services.d/nginx/run b/bazarr/rootfs/etc/services.d/nginx/run index 59d20fe581..e434541bf6 100644 --- a/bazarr/rootfs/etc/services.d/nginx/run +++ b/bazarr/rootfs/etc/services.d/nginx/run @@ -15,7 +15,7 @@ bashio::net.wait_for "$port" localhost 900 if [ -f "$CONFIG_LOCATION" ]; then if ! bashio::config.true "ingress_disabled"; then if ! bashio::config.has_value "connection_mode" || [ "$(bashio::config 'connection_mode')" != "noingress_auth" ]; then - if ! grep -q "base_url: /$slug" "$CONFIG_LOCATION"; then + if ! sed -n "/^general:/,/^[^ ]/ { /^ base_url: \/$slug$/p; }" "$CONFIG_LOCATION" | grep -q .; then bashio::log.warning "BaseUrl not set properly, restarting" # Must start with / for Flask blueprint registration. Scoped to # the general: block only -- config.yaml also carries a base_url