API unable to filter prefixes on VRF when VRF is null (not present) #2763

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

Originally created by @Renji-FR on GitHub (Jul 25, 2019).

Environment

  • Python version: 3.6.9
  • NetBox version: 59139502ac7d (v2.6.1)

Steps to Reproduce

  1. Create a prefix without VRF (vrf = null)
{
            "id": 5,
            "family": {
                "value": 4,
                "label": "IPv4"
            },
            "prefix": "10.242.0.0/16",
            "site": {
                "id": 4,
                "url": "http://localhost:32768/api/dcim/sites/4/",
                "name": "mySite",
                "slug": "mysite"
            },
            "vrf": null,
            ...
}
  1. Try to get this prefix by prefixes API with VRF filter to null
    curl -H "Accept: application/json; indent=4" -H "Authorization: Token 0123456789abcdef0123456789abcdef01234567" "http://localhost:32768/api/ipam/prefixes/?vrf=null"

  2. With vrf_id field filter, it works correctly

Expected Behavior

Same result with vrf filter as vrf_id filter when filter value is null

Observed Behavior

vrf=null filter does not filter anything

Originally created by @Renji-FR on GitHub (Jul 25, 2019). ### Environment * Python version: 3.6.9 * NetBox version: 59139502ac7d (v2.6.1) ### Steps to Reproduce 1. Create a prefix without VRF (vrf = null) ```json { "id": 5, "family": { "value": 4, "label": "IPv4" }, "prefix": "10.242.0.0/16", "site": { "id": 4, "url": "http://localhost:32768/api/dcim/sites/4/", "name": "mySite", "slug": "mysite" }, "vrf": null, ... } ``` 2. Try to get this prefix by prefixes API with VRF filter to null `curl -H "Accept: application/json; indent=4" -H "Authorization: Token 0123456789abcdef0123456789abcdef01234567" "http://localhost:32768/api/ipam/prefixes/?vrf=null"` 3. With `vrf_id` field filter, it works correctly ### Expected Behavior Same result with `vrf` filter as `vrf_id` filter when filter value is null ### Observed Behavior `vrf=null` filter does not filter anything
adam closed this issue 2025-12-29 18:21:50 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 15, 2019):

The vrf filter matches on an assigned VRF object's rd field, which is a character string that cannot be null. Thus vrf=NULL can't work. You'll need to use the vrf_id filter to filter prefixes with no VRF assigned.

@jeremystretch commented on GitHub (Aug 15, 2019): The `vrf` filter matches on an assigned VRF object's `rd` field, which is a character string that cannot be null. Thus `vrf=NULL` can't work. You'll need to use the `vrf_id` filter to filter prefixes with no VRF assigned.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2763