ASN View search by partial number match does not work #11616

Closed
opened 2025-12-29 21:47:40 +01:00 by adam · 2 comments
Owner

Originally created by @dmulyalin on GitHub (Sep 16, 2025).

NetBox Edition

NetBox Community

NetBox Version

v4.3.7

Python Version

3.10

Steps to Reproduce

  1. Create asn in netbox e.g. 65000
  2. Try to search ASN by punching in number 65 into "Quick Search" field in ASN view or by using "Search" field in "Filters" tab

Expected Behavior

Return search results of ASNs that value been matched number even when match is partial.

Observed Behavior

Only returns ASNs that are exact match of the number inputted into search field.

Why current behavior is wrong:

This is search function, when somebody searches for something often times they do not know the exact value of the thing they are searching for or not searching for exact match altogether. Being able to find ASNs by partial number match is more expected behavior IMHO.

Originally created by @dmulyalin on GitHub (Sep 16, 2025). ### NetBox Edition NetBox Community ### NetBox Version v4.3.7 ### Python Version 3.10 ### Steps to Reproduce 1. Create asn in netbox e.g. 65000 2. Try to search ASN by punching in number 65 into "Quick Search" field in ASN view or by using "Search" field in "Filters" tab ### Expected Behavior Return search results of ASNs that value been matched number even when match is partial. ### Observed Behavior Only returns ASNs that are exact match of the number inputted into search field. Why current behavior is wrong: This is search function, when somebody searches for something often times they do not know the exact value of the thing they are searching for or not searching for exact match altogether. Being able to find ASNs by partial number match is more expected behavior IMHO.
adam added the netbox label 2025-12-29 21:47:40 +01:00
adam closed this issue 2025-12-29 21:47:40 +01:00
Author
Owner

@dmulyalin commented on GitHub (Sep 16, 2025):

it seems to me to achieve expected bahviour would need to replace this code:

qs_filter |= Q(asn=int(value))

With this:

        try:
            int(value)
            qs_filter |= Q(asn__icontains=value)
        except ValueError:
            pass
@dmulyalin commented on GitHub (Sep 16, 2025): it seems to me to achieve expected bahviour would need to replace this code: [ qs_filter |= Q(asn=int(value))](https://github.com/netbox-community/netbox/blob/5bfbca9a83cb85284e55e43d46e35d897ad795a8/netbox/ipam/filtersets.py#L280) With this: ``` try: int(value) qs_filter |= Q(asn__icontains=value) except ValueError: pass ```
Author
Owner

@jeremystretch commented on GitHub (Sep 16, 2025):

This is working as intended. Partial match on integers would lead to pollution of search results.

@jeremystretch commented on GitHub (Sep 16, 2025): This is working as intended. Partial match on integers would lead to pollution of search results.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11616