GraphQL: querying ip_address_list with filtering on a parent will not work even if the scheme describes this as StrFilterLookup #10527

Closed
opened 2025-12-29 21:32:38 +01:00 by adam · 2 comments
Owner

Originally created by @dxks on GitHub (Nov 29, 2024).

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.7

Python Version

3.11

Steps to Reproduce

Using a simple IP-Adress-List to get multiple ip-addresses for multiple prefixes:

query {
    ip_address_list (filters: {parent: {in_list: ["10.1.10.0/27", "10.100.10.0/27"]}}) {
        id
        address
    }
}

causing the error:

{
  "data": null,
  "errors": [
    {
      "message": "Cannot resolve keyword 'parent' into field. Choices are: address, assigned_object, assigned_object_id, assigned_object_type, assigned_object_type_id, bookmarks, comments, contacts, created, custom_field_data, description, dns_name, fhrpgroup, id, interface, journal_entries, last_updated, local_address, nat_inside, nat_inside_id, nat_outside, remote_address, role, services, status, subscriptions, tagged_items, tags, tenant, tenant_id, termination_a_ip, termination_z_ip, tunnel_terminations, vminterface, vrf, vrf_id",
      "locations": [
        {
          "line": 2,
          "column": 5
        }
      ],
      "path": [
        "ip_address_list"
      ]
    }
  ]
}

Expected Behavior

Querying the IP-Addresses for multiple Prefixes results in a list of all IPs. Unfortunately this is also not supported querying all Prefixes and retrieve the specific ip addresses in a prefix.

Observed Behavior

An error was raised showing that using parent in filters is not supported.

Originally created by @dxks on GitHub (Nov 29, 2024). ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.7 ### Python Version 3.11 ### Steps to Reproduce Using a simple IP-Adress-List to get multiple ip-addresses for multiple prefixes: ``` query { ip_address_list (filters: {parent: {in_list: ["10.1.10.0/27", "10.100.10.0/27"]}}) { id address } } ``` causing the error: ``` { "data": null, "errors": [ { "message": "Cannot resolve keyword 'parent' into field. Choices are: address, assigned_object, assigned_object_id, assigned_object_type, assigned_object_type_id, bookmarks, comments, contacts, created, custom_field_data, description, dns_name, fhrpgroup, id, interface, journal_entries, last_updated, local_address, nat_inside, nat_inside_id, nat_outside, remote_address, role, services, status, subscriptions, tagged_items, tags, tenant, tenant_id, termination_a_ip, termination_z_ip, tunnel_terminations, vminterface, vrf, vrf_id", "locations": [ { "line": 2, "column": 5 } ], "path": [ "ip_address_list" ] } ] } ``` ### Expected Behavior Querying the IP-Addresses for multiple Prefixes results in a list of all IPs. Unfortunately this is also not supported querying all Prefixes and retrieve the specific ip addresses in a prefix. ### Observed Behavior An error was raised showing that using parent in filters is not supported.
adam added the type: bugstatus: duplicatetopic: GraphQL labels 2025-12-29 21:32:38 +01:00
adam closed this issue 2025-12-29 21:32:38 +01:00
Author
Owner

@pl0xym0r commented on GitHub (Dec 2, 2024):

same issue as #17681 : use of parent as filter for IpRange and IpAddress

Even, using the doc for autotype_decorator :

For other filter fields a function needs to be created for Strawberry with the
naming convention filter_{fieldname} which is auto detected and called by
Strawberry, this function uses the filterset to handle the query.

modify search_by_parent by filter_parent didn't help.

@pl0xym0r commented on GitHub (Dec 2, 2024): same issue as #17681 : use of `parent` as filter for IpRange and IpAddress Even, using the doc for `autotype_decorator` : > For other filter fields a function needs to be created for Strawberry with the > naming convention `filter_{fieldname}` which is auto detected and called by > Strawberry, this function uses the filterset to handle the query. modify `search_by_parent` by `filter_parent` didn't help.
Author
Owner

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

This is fixed in my branch here:
https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign

Fixed query:

query getIpAddresses {
  resp:ip_address_list (filters: {parent: ["172.18.0.0/24", "172.17.0.0/24"]}){
    id
    address
    status
    description
    dns_name
    tenant {
      id
      name
    }
    assigned_object {
      __typename
      ... on InterfaceType {
        id
        name
      }
      ... on VMInterfaceType {
        id
        name
      }
    }
    custom_fields
  }
}

results:

{
  "data": {
    "resp": [
      {
        "id": "61",
        "address": "172.17.0.1/24",
        "status": "active",
        "description": "",
        "dns_name": "",
        "tenant": null,
        "assigned_object": null,
        "custom_fields": {}
      },
      {
        "id": "62",
        "address": "172.17.0.2/24",
        "status": "active",
        "description": "",
        "dns_name": "",
        "tenant": null,
        "assigned_object": null,
        "custom_fields": {}
      },
      {
        "id": "63",
        "address": "172.17.0.3/24",
        "status": "active",
        "description": "",
        "dns_name": "",
        "tenant": null,
        "assigned_object": null,
        "custom_fields": {}
      },
...continued

If you'll assign this to me I'll tag this in the PR.

@jeremypng commented on GitHub (Jan 23, 2025): This is fixed in my branch here: https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign Fixed query: ```graphql query getIpAddresses { resp:ip_address_list (filters: {parent: ["172.18.0.0/24", "172.17.0.0/24"]}){ id address status description dns_name tenant { id name } assigned_object { __typename ... on InterfaceType { id name } ... on VMInterfaceType { id name } } custom_fields } } ``` results: ```json { "data": { "resp": [ { "id": "61", "address": "172.17.0.1/24", "status": "active", "description": "", "dns_name": "", "tenant": null, "assigned_object": null, "custom_fields": {} }, { "id": "62", "address": "172.17.0.2/24", "status": "active", "description": "", "dns_name": "", "tenant": null, "assigned_object": null, "custom_fields": {} }, { "id": "63", "address": "172.17.0.3/24", "status": "active", "description": "", "dns_name": "", "tenant": null, "assigned_object": null, "custom_fields": {} }, ...continued ``` If you'll assign this to me I'll tag this in the PR.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10527