-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
netboxstatus: needs triageThis issue is awaiting triage by a maintainerThis issue is awaiting triage by a maintainertype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox Edition
NetBox Community
NetBox Version
4.4.8
Python Version
3.12
Steps to Reproduce
- Install Netbox with a fresh db
- Create a site, device role and a device type. Do NOT create any front port or rear port. No need to create any device.
- On the device type (not on a device), click on Add Components, create one rear port and one front port (RearPortTemplate and FrontPortTemplate).
- Using the REST API, list the Front Port Templates and check that there is exactly one result, connected to the Rear Port Template with id==1 :
$ curl -s -H "Authorization: Token $TOKEN" 'http://127.0.0.1:8000/api/dcim/front-port-templates/' | jq '.results[] | {id, display, rear_port}'
{
"id": 1,
"display": "front",
"rear_port": {
"id": 1,
"url": "http://127.0.0.1:8000/api/dcim/rear-port-templates/1/",
"display": "rear",
"name": "rear",
"description": ""
}
}
- Using the same API route, search for a Front Port Template connected to the Rear Port Template with id = 1 :
$ curl -s -H "Authorization: Token $TOKEN" 'http://127.0.0.1:8000/api/dcim/front-port-templates/?rear_port_id=1'
Expected Behavior
The API should return the same result found in Step 4.
Observed Behavior
{"rear_port_id":["Select a valid choice. 1 is not one of the available choices."]}
I suspect the issue is in class FrontPortTemplateFilterSet in netbox/dcim/filtersets.py: replacing queryset=RearPort.objects.all() by queryset=RearPortTemplate.objects.all() seems to fix the issue.
Note that in the feature branch, a front_port_id filter was added to RearPortTemplateFilterSet by 17d8f78 that most likely has the same issue (missing Template in the queryset).
I can provide PR if requested.
Metadata
Metadata
Assignees
Labels
netboxstatus: needs triageThis issue is awaiting triage by a maintainerThis issue is awaiting triage by a maintainertype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application