From 4744d18d7325097d9ef51a7955f987b4fed042f2 Mon Sep 17 00:00:00 2001 From: Brian O'Connor Date: Sat, 16 Nov 2024 10:24:29 -0500 Subject: [PATCH] Fix: Handle retry exception during authentication in Bluesound provider (#1778) --- music_assistant/providers/siriusxm/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/music_assistant/providers/siriusxm/__init__.py b/music_assistant/providers/siriusxm/__init__.py index e971c30ce..339e86229 100644 --- a/music_assistant/providers/siriusxm/__init__.py +++ b/music_assistant/providers/siriusxm/__init__.py @@ -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 @@ -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")