home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.18k stars 31.15k forks source link

Unknown error when browsing DNLA server (rclone serve dlna) #103643

Closed ameuret closed 6 months ago

ameuret commented 1 year ago

The problem

Rclone is launched using rclone serve dlna --addr 0.0.0.0:8080 /home/arnaud/over/movies/ and vlc can browse and play media fine (Linux & iPad).

What version of Home Assistant Core has the issue?

core-2023.11.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

dlna_dms

Link to integration documentation on our website

https://www.home-assistant.io/integrations/dlna_dms

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/dlna_dms/dms.py:489
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: November 7, 2023 at 10:05:43 (2 occurrences)
Last logged: 17:22:40

[1530321704] Error handling message: Unknown error (unknown_error) Arnaud Meuret from 192.168.1.130 (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36)
[1507327848] Error handling message: Unknown error (unknown_error) Arnaud Meuret from 192.168.1.130 (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 174, in websocket_browse_media
    media = await async_browse_media(hass, msg.get("media_content_id", ""))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 125, in async_browse_media
    item = await _get_media_item(hass, media_content_id, None).async_browse()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 79, in async_browse
    return await self.async_media_source().async_browse_media(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dms/media_source.py", line 112, in async_browse_media
    return await source.async_browse_media(media_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dms/dms.py", line 391, in async_browse_media
    return await self.async_browse_object(ROOT_OBJECT_ID)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dms/dms.py", line 139, in wrapper
    return await func(self, req_param)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dms/dms.py", line 489, in async_browse_object
    base_object = await self._device.async_browse_metadata(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/async_upnp_client/profiles/dlna.py", line 1456, in async_browse_metadata
    result = await self.async_browse(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/async_upnp_client/profiles/dlna.py", line 1444, in async_browse
    int(result["NumberReturned"]),
        ~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'NumberReturned'

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @chishm, mind taking a look at this issue as it has been labeled with an integration (dlna_dms) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `dlna_dms` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign dlna_dms` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


dlna_dms documentation dlna_dms source (message by IssueLinks)

issue-triage-workflows[bot] commented 10 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

ameuret commented 9 months ago

As of the latest release, this issue is still present. Here are the rclone-side logs:

2024/02/09 11:59:56 INFO  : /static/ContentDirectory.xml: 192.168.1.173:36026 GET 200
2024/02/09 11:59:56 INFO  : /static/ConnectionManager.xml: 192.168.1.173:36026 GET 200
2024/02/09 11:59:56 INFO  : /static/X_MS_MediaReceiverRegistrar.xml: 192.168.1.173:36026 GET 200
2024/02/09 11:59:56 INFO  : /ctl: 192.168.1.173:36026 POST 200 "urn:schemas-upnp-org:service:ConnectionManager:1#GetProtocolInfo"
2024/02/09 11:59:56 INFO  : /ctl: 192.168.1.173:36026 POST 200 "urn:schemas-upnp-org:service:ContentDirectory:1#GetSystemUpdateID"
2024/02/09 11:59:56 INFO  : /ctl: 192.168.1.173:36026 POST 200 "urn:schemas-upnp-org:service:ContentDirectory:1#GetSearchCapabilities"
2024/02/09 11:59:56 INFO  : /ctl: 192.168.1.173:36026 POST 200 "urn:schemas-upnp-org:service:ContentDirectory:1#GetSortCapabilities"
2024/02/09 11:59:56 INFO  : /static/rclone-48x48.png: 192.168.1.4:52253 GET 200
2024/02/09 11:59:56 INFO  : /static/rclone-120x120.png: 192.168.1.4:52253 GET 200
2024/02/09 11:59:56 INFO  : /static/X_MS_MediaReceiverRegistrar.xml: 192.168.1.4:52253 GET 200
2024/02/09 11:59:56 INFO  : /ctl: 192.168.1.4:52254 POST 200 "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1#IsAuthorized"
2024/02/09 11:59:56 INFO  : /static/ContentDirectory.xml: 192.168.1.4:52255 GET 200
2024/02/09 12:00:02 INFO  : /ctl: 192.168.1.173:48588 POST 200 "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"
issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

ameuret commented 6 months ago

Issue still active in 2024.5.5

chishm commented 6 months ago

This is a bug in rclone. When it returns a result for Browse with the flag "BrowseMetadata", it is not including the fields "TotalMatches" or "NumberReturned". According to the UPnP-av-ContentDirectory-v1-Service spec (section 2.7.4.2), these are not optional and should be set to 1 for both when "BrowseMetadata" is used.

Arguably dlna_dmr (and async-upnp-client) could be more tolerant here, but since rclone is open source it might be best to raise an issue there to fix it for all users.

chishm commented 6 months ago

PS: Also, hi and thank you for the bug report. I do appreciate that you've taken the time to report an issue, instead of ignoring it and the dlna_dmr component entirely.

ameuret commented 6 months ago

Issue reported

Thanks a lot for taking the time to dig into foreign code and my please accept my apologies for assuming that rclone was undoubtedly more mature than your component ! 🙇🏻

ameuret commented 6 months ago

The fix has been done in rclone and will find its way in the upcoming releases. :partying_face:

chishm commented 5 months ago

That's great news! Excellent work on getting the bug reported so well, you've made a good contribution to the open source community.