-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Unable to filter ip-addresses by assigned_object_type via REST API #17559
Comments
@Konunacmep which previous version of NetBox were you seeing this working in? I tried with v3.7 and it is not returning the interfaces using this query (see screenshot). |
Hi @arthanson, just checked, yes you are right. On 3.7.1, filtering by assigned_object_type does not return an error, but passes unfiltered values into the result. In my opinion, this is also incorrect behavior, because to search by a assigned object, filtering must be performed by a set of assigned_object_type and assigned_object_id fields (polymorphic relationship), assigned_object_id alone is not enough. |
This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically. |
Please do not close the case, as we are already talking about 2 unclosed bugs in the REST API ipam.ipaddresses:
|
IP addresses can filter be filtered by specifying the numeric ID of the assigned content type, e.g. |
Thanks for the answer. This is the "workaround" I am currently using to get around the problem. Although, as we found out in this case, this filter does not work at all. In my opinion, this is definitely a bug that appeared after the update from version 3 to 4. In GET requests, you will have to pass numeric ids, and in POST - strings, in responses also string type. The field should both accept and return the string type, as it was in version 3 and it described in the documentation: https://demo.netbox.dev/static/docs/rest-api/overview/#generic-relations. I would like to note for those who encountered this bug that when using numeric values of assigned_object_type id, these id's can be unique for each specific Netbox instance. The id values of the current Netbox instance should be looked up in /api/extras/object-types/ |
Deployment Type
Self-hosted
NetBox Version
v4.1.1
Python Version
3.11
Steps to Reproduce
Сan be reproduced on the demo.
Expected Behavior
Expecting response with filtered list of ip-addresses with specified assigned_object_type (as it was on version 3)
Observed Behavior
Regardless of the parameter value (dcim.interface/virtualization.vminterface/ipam.fhrpgroup) get a response:
"assigned_object_type": [
"Select a valid choice. That choice is not one of the available choices."
]
From the docs: "assigned_object_type - The content type of the assigned object, defined as
<app>.<model>
".It is noticed that the parameter accepts numeric values of identifiers from api/extras/object-types for GET requests and filtering works. However, for POST it responds with "'assigned_object_type': ["Invalid value. Specify a content type as '<app_label>.<model_name>'."]" and working with values defined as
<app>.<model>
.Initially the problem was noticed after the update from 3.7.1 to 4.0.8, however, the behavior is the same on a clean installation of 4.1.1.
The text was updated successfully, but these errors were encountered: