Skip to content

Filtering VLANGroup by vid_ranges.contains in GraphQL fails with “cannot cast type integer to int4range” #20497

@pheus

Description

@pheus

NetBox Edition

NetBox Community

NetBox Version

v4.4.2

Python Version

3.12

Steps to Reproduce

Filtering vlan_group_list by a scalar VLAN ID using the vid_ranges.contains GraphQL filter returns an error instead of matching groups whose VID ranges include the value.

  1. Ensure a VLANGroup exists with vid_ranges that include VLAN 10 (e.g., [1,11)).
  2. Run the GraphQL query below against /graphql/.
  3. The request fails with the error shown instead of returning the matching VLANGroup.
query MyQuery {
  vlan_group_list(filters: { vid_ranges: { contains: 10 } }) {
    id
    name
    vid_ranges
  }
}

Expected Behavior

The query should succeed and return all VLANGroup records whose vid_ranges include the given VLAN ID (e.g., 10), without errors.
If no groups match, the API should return an empty list. The response should include the requested fields for each matching group.

Observed Behavior

{
  "data": null,
  "errors": [
    {
      "message": "cannot cast type integer to int4range\nLINE 1: ... WHERE \"ipam_vlangroup\".\"vid_ranges\" @> (ARRAY[10])::int4...\n                                                             ^",
      "path": ["vlan_group_list"]
    }
  ]
}

Server traceback (excerpt)

django.db.utils.ProgrammingError: cannot cast type integer to int4range
LINE 1: ... "ipam_vlangroup"."vid_ranges" @> (ARRAY[10])::int4...
                                                             ^

Metadata

Metadata

Assignees

Labels

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

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions