Fix AttributeError when provider is temporarily unavailable (#3157)
authorDavid Bishop <teancom@users.noreply.github.com>
Mon, 16 Feb 2026 08:24:19 +0000 (00:24 -0800)
committerGitHub <noreply@github.com>
Mon, 16 Feb 2026 08:24:19 +0000 (09:24 +0100)
get_provider() can return None when a provider is temporarily
unavailable (e.g., during reload or network issues). Both
remove_item_from_library() and add_item_to_library() call
.library_edit_supported() on the result without a None check,
causing an AttributeError that surfaces as a 500 error.

Co-authored-by: David Bishop <git@gnuconsulting.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
music_assistant/controllers/music.py

index 391a559c19ff48fee4e6d005483ebd2c49b8e617..54bf9e6d7b41999f0498de8a727b1bf883fb4238 100644 (file)
@@ -865,7 +865,7 @@ class MusicController(CoreController):
             if not prov_mapping.in_library:
                 continue
             provider = self.mass.get_provider(prov_mapping.provider_instance)
-            if not provider.library_edit_supported(full_item.media_type):
+            if not provider or not provider.library_edit_supported(full_item.media_type):
                 continue
             if not provider.library_sync_back_enabled(full_item.media_type):
                 continue
@@ -899,7 +899,7 @@ class MusicController(CoreController):
         # add to provider(s) library first
         for prov_mapping in full_item.provider_mappings:
             provider = self.mass.get_provider(prov_mapping.provider_instance)
-            if not provider.library_edit_supported(full_item.media_type):
+            if not provider or not provider.library_edit_supported(full_item.media_type):
                 continue
             if not provider.library_sync_back_enabled(full_item.media_type):
                 continue