Skip to content

GraphQL StrFilterLookup filter on prefix field causes unexpected error with IPNetworkField #20422

@rinna11

Description

@rinna11

NetBox Edition

NetBox Community

NetBox Version

v4.4.1

Python Version

3.12

Steps to Reproduce

  1. Use GraphQL to query aggregate_list with the following filter:
aggregate_list(filters: {
  prefix: {
    prefix: {
      i_regex: "^(?!10\\.)[^:]+$"
    }
  }
}) {
  prefix
}
  1. Run the query.

Expected Behavior

  • The query should return prefixes that match the regex pattern (e.g., IPv6 only).
  • Same return we can expect not only for i_regex , but also for the other StrFilterLookup fields like exact, contains and so on.
  • No error should occur, since the query syntax is valid.

Observed Behavior

  • The query fails with the following error:
{
  "data": null,
  "errors": [
    {
      "message": "Unsupported lookup 'prefix__iregex' for IPNetworkField or join on the field not permitted.",
      "locations": [
        {
          "line": 36,
          "column": 3
        }
      ],
      "path": [
        "aggregate_list"
      ]
    }
  ]
}
  • We tried to other StrFilterLookup Fields, such as contains but it also did not work.
  • No results are returned.

Background:
Before upgrading to NetBox 4.4.1 from 4.1.11, we used the following GraphQL query to filter IPv6 prefixes:

aggregate_list(filters: {family: 6}) {
  prefix
}

This query worked correctly in version 4.1.11. However, after upgrading to 4.4.1, the family filter is no longer supported.
To work around this, we tried using a regex filter on the prefix field to exclude IPv4 addresses and target IPv6 only.

Metadata

Metadata

Assignees

Labels

netboxseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtopic: GraphQLtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions