Cannot filter ip range based on parent prefix
Deployment Type
Self-hosted
NetBox Version
v4.1.1
Python Version
3.12
Steps to Reproduce
Create the following graphql query:
{
ip_range_list(filters: {parent: {exact: "10.20.0.0/16"}}) {
id
}
}
Expected Behavior
I expect the same result as this API call:
/api/ipam/ip-ranges/?parent=10.20.0.0/16
And it is mentioned in this issue:
https://github.com/netbox-community/netbox/issues/13313
Also the IPRangeFilter graphql type has a parent: StrFilterLookup field.
Observed Behavior
Error is thrown:
{
"data": null,
"errors": [
{
"message": "Cannot resolve keyword 'parent' into field. Choices are: bookmarks, comments, contacts, created, custom_field_data, description, end_address, id, journal_entries, last_updated, mark_utilized, role, role_id, size, start_address, status, subscriptions, tagged_items, tags, tenant, tenant_id, vrf, vrf_id",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"ip_range_list"
]
}
]
}
Also affects ip address lists too.
Just to mention that we hit the same issue in an installation at one of our major customers in Germany. Hoping that there is a chance that this might increase the priority of fixing this bug.
If there is anything where I can support (keep in mind that I am not a Django developer) please let me know.
Please refer to https://netdev-community.slack.com/archives/C01P0FRSXRV/p1728394236998439 for latest state of discussion of this issue in Slack
Also affects ip address lists too.
Can confirm, we are also affected. Deployment version is 4.1.4.
Fixed in my branch here: https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign
fixed query:
query GetIPRange {
ip_range_list (filters: {parent: [""192.168.1.0/25""]}){
id
start_address
end_address
}
}
results:
{
"data": {
"ip_range_list": [
{
"id": "1",
"start_address": "192.168.1.0/22",
"end_address": "192.168.1.49/22"
},
{
"id": "2",
"start_address": "192.168.1.50/22",
"end_address": "192.168.1.99/22"
}
]
}
}
If you'll assign this to me I'll tag it in the PR
I expect the same result as this API call:
Please note that parity between the REST and GraphQL APIs is not and has never been a design goal. While they are generally comparable in functionality, specific filters available in one API might not be made available in the other, for various reasons. In this case, the parent filter has not been made available for IP ranges in the GraphQL API.
Per @jeremypng's comment above, this looks like it will be implemented as part of the GraphQL API change being explored for #7598.
Blocked by #7598
I can confirm that this has been resolved as part of the work on #7598. For example, the following query will return all IP ranges within the prefix 10.1.0.0/24:
{
ip_range_list(filters: {parent: "10.1.0.0/24"}) {
id
}
}
This change will be implemented in NetBox v4.3.