postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
827 stars 87 forks source link

[pyatv.support.mdns] exception during data handling #2352

Open Graefer opened 3 months ago

Graefer commented 3 months ago

Describe the bug

Every atvremote command starts with a bunch of assertion errors.

Error log

root@nodered:~# atvremote --version
atvremote 0.14.5
root@nodered:~# atvremote wizard
Looking for devices...
2024-02-11 20:12:05 ERROR [pyatv.core.mdns]: exception during data handling
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 305, in datagram_received
    delegate.datagram_received(data, addr)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 431, in datagram_received
    decoded_msg = DnsMessage().unpack(data)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 391, in unpack
    self.authorities.extend(
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 392, in <genexpr>
    DnsResource.unpack_read(buffer) for _ in range((header.nscount))
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 356, in unpack_read
    assert buffer.tell() == before_rd + rd_length
AssertionError
2024-02-11 20:12:06 ERROR [pyatv.core.mdns]: exception during data handling
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 305, in datagram_received
    delegate.datagram_received(data, addr)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 431, in datagram_received
    decoded_msg = DnsMessage().unpack(data)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 391, in unpack
    self.authorities.extend(
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 392, in <genexpr>
    DnsResource.unpack_read(buffer) for _ in range((header.nscount))
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 356, in unpack_read
    assert buffer.tell() == before_rd + rd_length
AssertionError
2024-02-11 20:12:06 ERROR [pyatv.core.mdns]: exception during data handling
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 305, in datagram_received
    delegate.datagram_received(data, addr)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 431, in datagram_received
    decoded_msg = DnsMessage().unpack(data)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 391, in unpack
    self.authorities.extend(
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 392, in <genexpr>
    DnsResource.unpack_read(buffer) for _ in range((header.nscount))
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 356, in unpack_read
    assert buffer.tell() == before_rd + rd_length
AssertionError
2024-02-11 20:12:07 ERROR [pyatv.core.mdns]: exception during data handling
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 305, in datagram_received
    delegate.datagram_received(data, addr)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 431, in datagram_received
    decoded_msg = DnsMessage().unpack(data)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 386, in unpack
    self.answers.extend(
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 387, in <genexpr>
    DnsResource.unpack_read(buffer) for _ in range((header.ancount))
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 356, in unpack_read
    assert buffer.tell() == before_rd + rd_length
AssertionError
2024-02-11 20:12:08 ERROR [pyatv.core.mdns]: exception during data handling
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 305, in datagram_received
    delegate.datagram_received(data, addr)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/core/mdns.py", line 431, in datagram_received
    decoded_msg = DnsMessage().unpack(data)
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 386, in unpack
    self.answers.extend(
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 387, in <genexpr>
    DnsResource.unpack_read(buffer) for _ in range((header.ancount))
  File "/usr/local/lib/python3.9/dist-packages/pyatv/support/dns.py", line 356, in unpack_read
    assert buffer.tell() == before_rd + rd_length
AssertionError
Found the following devices:
    Name          Model           Address

How to reproduce the bug?

Every atvremote wizard or atvremote scan.

What is expected behavior?

Every atvremote wizard or atvremote scan

Operating System

Debian 11

Python

3.9

pyatv

0.14.5

Device

AppleTV HD tvOS 17.3

Additional context

Installed in virtual environment