OpenAPI (Swagger) query of Prefixes does not allow "null" vrf or vrf_id #8666

Closed
opened 2025-12-29 20:39:37 +01:00 by adam · 4 comments
Owner

Originally created by @geoffdavis on GitHub (Sep 22, 2023).

NetBox version

v3.6.1

Python version

3.11

Steps to Reproduce

  1. Open Swagger API page
  2. Attempt to query for global VRF only
    a. Attempt to set vrf_id to null or "null" OR
    b. Attempt to use vrf__empty

Expected Behavior

I should get valid results, ie, receive a list of prefixes with no VRF assigned.

By comparison, it works "fine" in GraphQL land, and with plain curl commands, ie:

{
  prefix_list(contains: "172.16.150.142", family: 4, vrf_id: "null") {
    vrf {
      id
      name
    }
    prefix
  }

which results in:

{
  "data": {
    "prefix_list": [
      {
        "vrf": null,
        "prefix": "172.16.0.0/16"
      },
      {
        "vrf": null,
        "prefix": "172.16.150.0/23"
      },
      {
        "vrf": null,
        "prefix": "172.16.150.128/28"
      }
    ]
  }
}

Also works when run directly from CURL, i.e.:

curl -X 'GET' \
  "https://${HOSTNAME}/api/ipam/prefixes/?contains=172.16.150.142&vrf_id=null" \
  -H 'accept: application/json' \
  -H "Authorization: Token $NETBOX_API_TOKEN" | jq '.results.[] | .prefix,.vrf'

which results in:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2025  100  2025    0     0   9735      0 --:--:-- --:--:-- --:--:-- 10074
"172.16.0.0/16"
null
"172.16.150.0/23"
null
"172.16.150.128/28"
null

Observed Behavior

index0errorValue must be an integer
Screen Shot 2023-09-22 at 10 03 39 AM

Originally created by @geoffdavis on GitHub (Sep 22, 2023). ### NetBox version v3.6.1 ### Python version 3.11 ### Steps to Reproduce 1. Open Swagger API page 2. Attempt to query for global VRF only a. Attempt to set vrf_id to null or "null" *OR* b. Attempt to use `vrf__empty` ### Expected Behavior I should get valid results, ie, receive a list of prefixes with no VRF assigned. By comparison, it works "fine" in GraphQL land, and with plain curl commands, ie: ```GraphQL { prefix_list(contains: "172.16.150.142", family: 4, vrf_id: "null") { vrf { id name } prefix } ``` which results in: ```json { "data": { "prefix_list": [ { "vrf": null, "prefix": "172.16.0.0/16" }, { "vrf": null, "prefix": "172.16.150.0/23" }, { "vrf": null, "prefix": "172.16.150.128/28" } ] } } ``` Also works when run directly from CURL, i.e.: ```shell curl -X 'GET' \ "https://${HOSTNAME}/api/ipam/prefixes/?contains=172.16.150.142&vrf_id=null" \ -H 'accept: application/json' \ -H "Authorization: Token $NETBOX_API_TOKEN" | jq '.results.[] | .prefix,.vrf' ``` which results in: ```none % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2025 100 2025 0 0 9735 0 --:--:-- --:--:-- --:--:-- 10074 "172.16.0.0/16" null "172.16.150.0/23" null "172.16.150.128/28" null ``` ### Observed Behavior ```index0errorValue must be an integer``` <img width="398" alt="Screen Shot 2023-09-22 at 10 03 39 AM" src="https://github.com/netbox-community/netbox/assets/146506/4d3e84f0-492d-4fff-bb81-1af729978758">
adam closed this issue 2025-12-29 20:39:37 +01:00
Author
Owner

@arthanson commented on GitHub (Oct 10, 2023):

Looks like the lookup maps https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/filtersets.py#L112 need to be added to drf-spectacular bindings in https://github.com/netbox-community/netbox/blob/develop/netbox/core/api/schema.py

@arthanson commented on GitHub (Oct 10, 2023): Looks like the lookup maps https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/filtersets.py#L112 need to be added to drf-spectacular bindings in https://github.com/netbox-community/netbox/blob/develop/netbox/core/api/schema.py
Author
Owner

@github-actions[bot] commented on GitHub (Jan 9, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jan 9, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (May 16, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (May 16, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jun 15, 2024):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jun 15, 2024): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8666