From 20f348eb9e5a1eb757061e758f6cf1a6d7c168fd Mon Sep 17 00:00:00 2001 From: Barely Removable Date: Wed, 26 Aug 2026 09:29:39 -0700 Subject: [PATCH] Fix Settings-saved API keys never actually being used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every *_API_KEY was read from the env var once at startup and never checked against settings.json again, so saving a new key on the Settings page updated the file but had zero effect on real requests — reported live as "SABnzbd rejected the API key" right after rotating and saving a new one there. A saved key now overrides the .env value at startup, matching what the Settings page's own toast already says ("restart the container to apply"). Co-Authored-By: Claude Sonnet 5 --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.py b/app.py index e95eb4b..b2a8399 100644 --- a/app.py +++ b/app.py @@ -164,6 +164,17 @@ OMBI_PORT = os.environ.get("OMBI_PORT", "3579") OMBI_URL = f"http://{OMBI_HOST}:{OMBI_PORT}" OMBI_API_KEY = os.environ.get("OMBI_API_KEY", "") +# A key saved via the Settings page lives in settings.json and must win over +# the .env value here — otherwise "Save" on that page silently does nothing +# for anything that actually calls out to the service. +_saved_settings = load_settings() +SONARR_API_KEY = _saved_settings.get("sonarr_api_key") or SONARR_API_KEY +RADARR_API_KEY = _saved_settings.get("radarr_api_key") or RADARR_API_KEY +SABNZBD_API_KEY = _saved_settings.get("sabnzbd_api_key") or SABNZBD_API_KEY +TAUTULLI_API_KEY = _saved_settings.get("tautulli_api_key") or TAUTULLI_API_KEY +PROWLARR_API_KEY = _saved_settings.get("prowlarr_api_key") or PROWLARR_API_KEY +OMBI_API_KEY = _saved_settings.get("ombi_api_key") or OMBI_API_KEY + RT_HEADERS = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "Accept-Language": "en-US,en;q=0.9",