Skip to content

Commit

Permalink
Fix: Handle retry exception during authentication in Bluesound provid…
Browse files Browse the repository at this point in the history
…er (#1778)
  • Loading branch information
btoconnor authored Nov 16, 2024
1 parent 7d8e398 commit 4744d18
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion music_assistant/providers/siriusxm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Radio,
)
from music_assistant_models.streamdetails import StreamDetails
from tenacity import RetryError

from music_assistant.helpers.util import select_free_port
from music_assistant.helpers.webserver import Webserver
Expand Down Expand Up @@ -136,7 +137,18 @@ async def handle_async_init(self) -> None:
)

self.logger.info("Authenticating with SiriusXM")
if not await self._client.authenticate():
try:
if not await self._client.authenticate():
raise LoginFailed("Could not login to SiriusXM")
except RetryError:
# It looks like there's a bug in the sxm-client code
# where it won't return False if there's bad credentials.
# Due to the retry logic, it's attempting to log in multiple
# times and then finally raises an unrelated exception,
# rather than returning False or raising the package's
# AuthenticationError.
# Therefore, we're resorting to catching the RetryError
# here and recognizing it as a login failure.
raise LoginFailed("Could not login to SiriusXM")

self.logger.info("Successfully authenticated")
Expand Down

0 comments on commit 4744d18

Please sign in to comment.