Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot search virtual device context by name #13100

Closed
uedvt359 opened this issue Jul 6, 2023 · 2 comments · Fixed by #13103
Closed

Cannot search virtual device context by name #13100

uedvt359 opened this issue Jul 6, 2023 · 2 comments · Fixed by #13103
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@uedvt359
Copy link

uedvt359 commented Jul 6, 2023

NetBox version

3.5.4

Python version

3.8

Steps to Reproduce

reproduced on demo.netbox.dev. it does not matter if any VDCs exist

  1. search for a VDC by name, like so: https://demo.netbox.dev/dcim/virtual-device-contexts/?q=asdf

Expected Behavior

a list of VDCs matching the name asdf is returned

Observed Behavior

the following server error is returned:

<class 'ValueError'>

Field 'identifier' expected a number but got 'asdf'.

Python version: 3.8.10
NetBox version: 3.5.4
@uedvt359 uedvt359 added the type: bug A confirmed report of unexpected behavior in the application label Jul 6, 2023
@kkthxbye-code kkthxbye-code added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Jul 6, 2023
@kkthxbye-code
Copy link
Contributor

kkthxbye-code commented Jul 6, 2023

Issue is here:

Q(identifier=value.strip())

The search method searches an integer field without checking if the query is an integer. So it works for q=1 but not for q=string.

An example of how we've done this other places:

try:
qs_filter |= Q(asns__asn=int(value.strip()))
except ValueError:
pass

@uedvt359
Copy link
Author

uedvt359 commented Jul 6, 2023

just as a quick aside, searching by name specifically does work with e.g. https://demo.netbox.dev/dcim/virtual-device-contexts/?name=foo (as with other search forms, name is not surfaced on the UI, but modifying the URL works)

@abhi1693 abhi1693 added the severity: low Does not significantly disrupt application functionality, or a workaround is available label Jul 6, 2023
@abhi1693 abhi1693 self-assigned this Jul 6, 2023
@abhi1693 abhi1693 added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Jul 6, 2023
abhi1693 added a commit that referenced this issue Jul 6, 2023
jeremystretch pushed a commit that referenced this issue Jul 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants