More gracefully handle DLNA errors
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 22 Feb 2026 13:44:14 +0000 (14:44 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 22 Feb 2026 13:44:14 +0000 (14:44 +0100)
music_assistant/providers/dlna/helpers.py

index 7258c49edd748bbc0cbb4f08343b1935e042405c..8f525eafc9c1fd471411284a0cdad6a7c0c5e4f1 100644 (file)
@@ -2,6 +2,7 @@
 
 from __future__ import annotations
 
+import xml.etree.ElementTree as ET
 from typing import TYPE_CHECKING
 
 from aiohttp.web import Request, Response
@@ -40,7 +41,15 @@ class DLNANotifyServer(UpnpNotifyServer):  # type: ignore[misc,unused-ignore]
             body=await request.text(),
         )
 
-        status = await self.event_handler.handle_notify(http_request)
+        try:
+            status = await self.event_handler.handle_notify(http_request)
+        except ET.ParseError as err:
+            self.mass.logger.debug(
+                "Ignoring malformed XML in DLNA notify from %s: %s",
+                request.remote,
+                err,
+            )
+            return Response(status=400)
 
         return Response(status=status)