Skip to content

netbios: nbns_resolve with a list of names now raises TypeError: unhashable type: 'list' (since #5115) #5202

Description

@IcantFind-a-username

Brief description

Since #5115 ("netbios: key the NBNS resolver cache by name"), calling nbns_resolve with a list of names fails in the cache lookup, because the list is used inside the cache key (qname, raw). Before #5115 the same call did not fail there: it went on to build the request from the list and pass it to sr1.

The type hint says qname: str, so a list may simply not be supported; if so, please close this. Reporting it because the behavior changed with the cache change, and scapy fields otherwise accept lists (one packet per value).

Scapy version

master at c5e9a5b (2026-09-26)

Python version

3.10

Operating system

Linux (Docker)

Additional environment information

No response

How to reproduce

from unittest import mock
from scapy.layers.netbios import nbns_resolve

with mock.patch("scapy.layers.netbios.conf.route.get_if_bcast", return_value=["192.0.2.255"]):
    nbns_resolve(["ALPHA", "BETA"], iface="test")

Actual result

  File ".../scapy/config.py", line 395, in __contains__
    if not super(CacheInstance, self).__contains__(item):
TypeError: unhashable type: 'list'

Expected result

Either the pre-#5115 behavior, or a clear error saying that only a single name is accepted. (An empty list now fails the same way in the cache lookup; before #5115 it failed later, while sending.)

Related resources

#5115 (cc @KernelClint). Found by differential testing of recent pull requests and reproduced by hand on current master.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions