GraphQL PrefixFilter prefix:contains doesn't work anymore #11367

Closed
opened 2025-12-29 21:44:15 +01:00 by adam · 1 comment
Owner

Originally created by @valentinesd on GitHub (Jul 9, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.3.3

Python Version

3.10

Steps to Reproduce

After upgrading to v4.3.3, when running a GraphQL query for prefix_list and filtering for prefixes that contain an IP, it returns an empty result, the behavior seems to just be doing substring matching.

This behavior was working in version v4.0.11.

Expected Behavior

Match the behavior of the REST API (which still works as expected in v4.3.3), where the query returns a list of prefixes where the IP Address is part of the Prefix.

curl -X 'GET' \
  'https://<redacted>/api/ipam/prefixes/?contains=172.20.48.186' \
  -H 'accept: application/json' \
  -H 'Cookie: sessionid=<redacted>'
{
  "count": 5,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 35,
      "prefix": "172.16.0.0/12",
...
    },
    {
      "id": 711,
      "prefix": "172.20.48.0/21",
...
    },
    {
      "id": 712,
      "prefix": "172.20.48.0/22",
...
    },
    {
      "id": 111593,
      "prefix": "172.20.48.128/25",
...
    },
    {
      "id": 126933,
      "prefix": "172.20.48.184/30",
...
    }
  ]
...
}

Observed Behavior

Example query using the full IP Address

query {
  prefix_list(
    filters: {prefix: {contains: "172.20.48.186"}}
  ) {
    id
    prefix
  }
}
{
  "data": {
    "prefix_list": []
  }
}

Example query using a substring of the IP Address

query {
  prefix_list(
    filters: {prefix: {contains: "172.20.48.1"}}
  ) {
    id
    prefix
  }
}
{
  "data": {
    "prefix_list": [
      {
        "id": "2232",
        "prefix": "172.20.48.16/29"
      },
      {
        "id": "111593",
        "prefix": "172.20.48.128/25"
      },
      {
        "id": "130185",
        "prefix": "172.20.48.128/30"
      },
      {
        "id": "112860",
        "prefix": "172.20.48.132/30"
      },
      {
        "id": "112861",
        "prefix": "172.20.48.136/30"
      },
      {
        "id": "112862",
        "prefix": "172.20.48.140/30"
      },
      {
        "id": "112864",
        "prefix": "172.20.48.148/30"
      },
      {
        "id": "112865",
        "prefix": "172.20.48.152/30"
      },
      {
        "id": "112866",
        "prefix": "172.20.48.156/30"
      },
      {
        "id": "112868",
        "prefix": "172.20.48.164/30"
      },
      {
        "id": "112869",
        "prefix": "172.20.48.168/30"
      },
      {
        "id": "112871",
        "prefix": "172.20.48.176/30"
      },
      {
        "id": "126933",
        "prefix": "172.20.48.184/30"
      }
    ]
  }
}
Originally created by @valentinesd on GitHub (Jul 9, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.3.3 ### Python Version 3.10 ### Steps to Reproduce After upgrading to v4.3.3, when running a GraphQL query for `prefix_list` and filtering for prefixes that contain an IP, it returns an empty result, the behavior seems to just be doing substring matching. This behavior was working in version v4.0.11. ### Expected Behavior Match the behavior of the REST API (which still works as expected in v4.3.3), where the query returns a list of prefixes where the IP Address is part of the Prefix. ``` curl -X 'GET' \ 'https://<redacted>/api/ipam/prefixes/?contains=172.20.48.186' \ -H 'accept: application/json' \ -H 'Cookie: sessionid=<redacted>' ``` ``` { "count": 5, "next": null, "previous": null, "results": [ { "id": 35, "prefix": "172.16.0.0/12", ... }, { "id": 711, "prefix": "172.20.48.0/21", ... }, { "id": 712, "prefix": "172.20.48.0/22", ... }, { "id": 111593, "prefix": "172.20.48.128/25", ... }, { "id": 126933, "prefix": "172.20.48.184/30", ... } ] ... } ``` ### Observed Behavior Example query using the full IP Address ``` query { prefix_list( filters: {prefix: {contains: "172.20.48.186"}} ) { id prefix } } ``` ``` { "data": { "prefix_list": [] } } ``` Example query using a substring of the IP Address ``` query { prefix_list( filters: {prefix: {contains: "172.20.48.1"}} ) { id prefix } } ``` ``` { "data": { "prefix_list": [ { "id": "2232", "prefix": "172.20.48.16/29" }, { "id": "111593", "prefix": "172.20.48.128/25" }, { "id": "130185", "prefix": "172.20.48.128/30" }, { "id": "112860", "prefix": "172.20.48.132/30" }, { "id": "112861", "prefix": "172.20.48.136/30" }, { "id": "112862", "prefix": "172.20.48.140/30" }, { "id": "112864", "prefix": "172.20.48.148/30" }, { "id": "112865", "prefix": "172.20.48.152/30" }, { "id": "112866", "prefix": "172.20.48.156/30" }, { "id": "112868", "prefix": "172.20.48.164/30" }, { "id": "112869", "prefix": "172.20.48.168/30" }, { "id": "112871", "prefix": "172.20.48.176/30" }, { "id": "126933", "prefix": "172.20.48.184/30" } ] } } ```
adam added the type: bugstatus: duplicate labels 2025-12-29 21:44:15 +01:00
adam closed this issue 2025-12-29 21:44:15 +01:00
Author
Owner

@valentinesd commented on GitHub (Jul 9, 2025):

Apologies for not finding it sooner, but this looks like a duplicate of #19812

@valentinesd commented on GitHub (Jul 9, 2025): Apologies for not finding it sooner, but this looks like a duplicate of #19812
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11367