Fix: Subsonic: Handle uninitialized port config value (#2263)
authorEric Munson <eric@munsonfam.org>
Tue, 1 Jul 2025 21:43:21 +0000 (17:43 -0400)
committerGitHub <noreply@github.com>
Tue, 1 Jul 2025 21:43:21 +0000 (23:43 +0200)
Fix uninitialized port config value

The or construction does not seem to protect against None value when
there are tranformations applied in the lhs (or evaluates after the
str() and int() conversions. This leads to problems when no value is set
for port. Change back to the more verbose if port else 443 construction
to fix this.

Fixes: https://github.com/music-assistant/support/issues/4086
Signed-off-by: Eric B Munson <eric@munsonfam.org>
music_assistant/providers/opensubsonic/sonic_provider.py

index c6b6cf3d06794392ff7cfb3d872555b5a16b4a41..5a75e532f445f16a9bf3251b5db183c3ea369daf 100644 (file)
@@ -99,7 +99,7 @@ class OpenSonicProvider(MusicProvider):
     async def handle_async_init(self) -> None:
         """Set up the music provider and test the connection."""
         port = self.config.get_value(CONF_PORT)
-        port = int(str(port)) or 443
+        port = int(str(port)) if port is not None else 443
         path = self.config.get_value(CONF_PATH)
         if path is None:
             path = ""