Cannot filter ip range based on parent prefix #10325

Closed
opened 2025-12-29 21:29:59 +01:00 by adam · 7 comments
Owner

Originally created by @kuon on GitHub (Oct 6, 2024).

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"
      ]
    }
  ]
}
Originally created by @kuon on GitHub (Oct 6, 2024). ### 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" ] } ] } ```
adam added the type: bugstatus: acceptednetboxtopic: GraphQLseverity: low labels 2025-12-29 21:29:59 +01:00
adam closed this issue 2025-12-29 21:30:00 +01:00
Author
Owner

@tom0010 commented on GitHub (Oct 7, 2024):

Also affects ip address lists too.

@tom0010 commented on GitHub (Oct 7, 2024): Also affects ip address lists too.
Author
Owner

@svluder commented on GitHub (Oct 8, 2024):

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

@svluder commented on GitHub (Oct 8, 2024): 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
Author
Owner

@loulecrivain commented on GitHub (Oct 23, 2024):

Also affects ip address lists too.

Can confirm, we are also affected. Deployment version is 4.1.4.

@loulecrivain commented on GitHub (Oct 23, 2024): > Also affects ip address lists too. Can confirm, we are also affected. Deployment version is 4.1.4.
Author
Owner

@jeremypng commented on GitHub (Jan 23, 2025):

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

@jeremypng commented on GitHub (Jan 23, 2025): Fixed in my branch here: https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign fixed query: ```graphql query GetIPRange { ip_range_list (filters: {parent: [""192.168.1.0/25""]}){ id start_address end_address } } ``` results: ```json { "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
Author
Owner

@jeremystretch commented on GitHub (Feb 7, 2025):

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.

@jeremystretch commented on GitHub (Feb 7, 2025): > 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.
Author
Owner

@jeremystretch commented on GitHub (Feb 7, 2025):

Blocked by #7598

@jeremystretch commented on GitHub (Feb 7, 2025): Blocked by #7598
Author
Owner

@jeremystretch commented on GitHub (Mar 10, 2025):

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.

@jeremystretch commented on GitHub (Mar 10, 2025): 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: ```graphql { ip_range_list(filters: {parent: "10.1.0.0/24"}) { id } } ``` This change will be implemented in NetBox v4.3.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10325