Missing lookup filters for interface object fields #9827

Closed
opened 2025-12-29 21:23:16 +01:00 by adam · 7 comments
Owner

Originally created by @cybarox on GitHub (Jun 11, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.5

Python Version

3.11

Linked Issue

#16261
#16354

Steps to Reproduce

NetBox v4.0.x - Observed Behavior

  1. Setup a fresh NetBox v4.0.x installation
  2. Import new Site
    ---
    name: Test Site 
    slug: test_site
    status: active
    facility: Facility 1
    
  3. Import Manufacturer
    --- 
    name: Test Manufacturer
    slug: test_manufacturer
    
  4. Import Device Type
    ---
    manufacturer: Test Manufacturer
    model: Test Model
    slug: test_model
    u_height: 0
    interfaces:
    - name: eth0
      type: 1000base-t
    - name: eth1
      type: 1000base-t
    
  5. Import Device Role
    ---
    name: Test Role
    slug: test_role
    color: ffff00
    
  6. Import Devices
    ---
    - name: Test Device 1
      role: Test Role
      manufacturer: Test Manufacturer
      device_type: Test Model
      slug: test_device_1
      site: Test Site
      status: active
    - name: Test Device 2
      role: Test Role
      manufacturer: Test Manufacturer
      device_type: Test Model
      slug: test_device_1
      site: Test Site
      status: active
    
  7. Import Interfaces
    ---
    - id: 1
      mac_address: DE:AD:BE:EF:00:69
    - id: 2
      mac_address: 00:00:00:00:00:00
    - id: 3
      mac_address: DE:AD:BE:EF:00:42
    - id: 4
      mac_address: 00:00:00:00:00:01
    
  8. Use GraphQL Webgui Query
    Query:
    query vendor_query($mac_vendor: [String!], $facility_name: String!, $device_role: [String!]) {
      site_list(filters: {facility: {exact: $facility_name}}) {
        name
        devices(filters: {role: $device_role}) {
          name
          interfaces(filters: {mac_address: {i_contains: $mac_vendor}}) {
            name
            mac_address
          }
        }
      }
    }
    
    Query Variables
    {
      "mac_vendor": "DE:AD",
      "facility_name": "Facility 1",
      "device_role": "test_role"
    }
    
  9. Query Result
    {
      "data": null,
      "errors": [
        {
          "message": "String cannot represent a non string value: {i_contains: $mac_vendor}",
          "locations": [
            {
              "line": 6,
              "column": 41
            }
          ]
        }
      ]
    }
    

NetBox v3.7.6 - Expected Behavior

  1. Setup a fresh NetBox v3.7.6 installation
  2. Import new Site
    ---
    name: Test Site 
    slug: test_site
    status: active
    facility: Facility 1
    
  3. Import Manufacturer
    --- 
    name: Test Manufacturer
    slug: test_manufacturer
    
  4. Import Device Type
    ---
    manufacturer: Test Manufacturer
    model: Test Model
    slug: test_model
    u_height: 0
    interfaces:
    - name: eth0
      type: 1000base-t
    - name: eth1
      type: 1000base-t
    
  5. Import Device Role
    ---
    name: Test Role
    slug: test_role
    color: ffff00
    
  6. Import Devices
    ---
    - name: Test Device 1
      role: Test Role
      manufacturer: Test Manufacturer
      device_type: Test Model
      slug: test_device_1
      site: Test Site
      status: active
    - name: Test Device 2
      role: Test Role
      manufacturer: Test Manufacturer
      device_type: Test Model
      slug: test_device_1
      site: Test Site
      status: active
    
  7. Import Interfaces
    ---
    - id: 1
      mac_address: DE:AD:BE:EF:00:69
    - id: 2
      mac_address: 00:00:00:00:00:00
    - id: 3
      mac_address: DE:AD:BE:EF:00:42
    - id: 4
      mac_address: 00:00:00:00:00:01
    
  8. Use GraphQL Webgui Query
    Query:
    query vendor_query($mac_vendor: [String!], $facility_name: [String!], $device_role: [String!]) {
      site_list(facility: $facility_name) {
        name
        devices(role: $device_role) {
          name
          interfaces(mac_address__ic: $mac_vendor) {
            name
            mac_address
          }
        }
      }
    }
    
    Query Variables
    {
      "mac_vendor": "DE:AD",
      "facility_name": "Facility 1",
      "device_role": "test_role"
    }
    
  9. Query Result
    {
      "data": {
        "site_list": [
          {
            "name": "Test Site",
            "devices": [
              {
                "name": "Test Device 1",
                "interfaces": [
                  {
                    "name": "eth0",
                    "mac_address": "DE:AD:BE:EF:00:69"
                  }
                ]
              },
              {
                "name": "Test Device 2",
                "interfaces": [
                  {
                    "name": "eth0",
                    "mac_address": "DE:AD:BE:EF:00:42"
                  }
                ]
              }
            ]
          }
        ]
      }
    }
    
Originally created by @cybarox on GitHub (Jun 11, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.5 ### Python Version 3.11 ### Linked Issue #16261 #16354 ### Steps to Reproduce #### NetBox v4.0.x - Observed Behavior 1. Setup a fresh NetBox v4.0.x installation 2. Import new Site ```yaml --- name: Test Site slug: test_site status: active facility: Facility 1 ``` 3. Import Manufacturer ```yaml --- name: Test Manufacturer slug: test_manufacturer ``` 4. Import Device Type ```yaml --- manufacturer: Test Manufacturer model: Test Model slug: test_model u_height: 0 interfaces: - name: eth0 type: 1000base-t - name: eth1 type: 1000base-t ``` 5. Import Device Role ```yaml --- name: Test Role slug: test_role color: ffff00 ``` 6. Import Devices ```yaml --- - name: Test Device 1 role: Test Role manufacturer: Test Manufacturer device_type: Test Model slug: test_device_1 site: Test Site status: active - name: Test Device 2 role: Test Role manufacturer: Test Manufacturer device_type: Test Model slug: test_device_1 site: Test Site status: active ``` 7. Import Interfaces ```yaml --- - id: 1 mac_address: DE:AD:BE:EF:00:69 - id: 2 mac_address: 00:00:00:00:00:00 - id: 3 mac_address: DE:AD:BE:EF:00:42 - id: 4 mac_address: 00:00:00:00:00:01 ``` 8. Use GraphQL Webgui Query ##### Query: ```graphql query vendor_query($mac_vendor: [String!], $facility_name: String!, $device_role: [String!]) { site_list(filters: {facility: {exact: $facility_name}}) { name devices(filters: {role: $device_role}) { name interfaces(filters: {mac_address: {i_contains: $mac_vendor}}) { name mac_address } } } } ``` ##### Query Variables ```json { "mac_vendor": "DE:AD", "facility_name": "Facility 1", "device_role": "test_role" } ``` 9. Query Result ```json { "data": null, "errors": [ { "message": "String cannot represent a non string value: {i_contains: $mac_vendor}", "locations": [ { "line": 6, "column": 41 } ] } ] } ``` #### NetBox v3.7.6 - Expected Behavior 1. Setup a fresh NetBox v3.7.6 installation 2. Import new Site ```yaml --- name: Test Site slug: test_site status: active facility: Facility 1 ``` 3. Import Manufacturer ```yaml --- name: Test Manufacturer slug: test_manufacturer ``` 4. Import Device Type ```yaml --- manufacturer: Test Manufacturer model: Test Model slug: test_model u_height: 0 interfaces: - name: eth0 type: 1000base-t - name: eth1 type: 1000base-t ``` 5. Import Device Role ```yaml --- name: Test Role slug: test_role color: ffff00 ``` 6. Import Devices ```yaml --- - name: Test Device 1 role: Test Role manufacturer: Test Manufacturer device_type: Test Model slug: test_device_1 site: Test Site status: active - name: Test Device 2 role: Test Role manufacturer: Test Manufacturer device_type: Test Model slug: test_device_1 site: Test Site status: active ``` 7. Import Interfaces ```yaml --- - id: 1 mac_address: DE:AD:BE:EF:00:69 - id: 2 mac_address: 00:00:00:00:00:00 - id: 3 mac_address: DE:AD:BE:EF:00:42 - id: 4 mac_address: 00:00:00:00:00:01 ``` 8. Use GraphQL Webgui Query ##### Query: ```graphql query vendor_query($mac_vendor: [String!], $facility_name: [String!], $device_role: [String!]) { site_list(facility: $facility_name) { name devices(role: $device_role) { name interfaces(mac_address__ic: $mac_vendor) { name mac_address } } } } ``` ##### Query Variables ```json { "mac_vendor": "DE:AD", "facility_name": "Facility 1", "device_role": "test_role" } ``` 9. Query Result ```json { "data": { "site_list": [ { "name": "Test Site", "devices": [ { "name": "Test Device 1", "interfaces": [ { "name": "eth0", "mac_address": "DE:AD:BE:EF:00:69" } ] }, { "name": "Test Device 2", "interfaces": [ { "name": "eth0", "mac_address": "DE:AD:BE:EF:00:42" } ] } ] } ] } } ```
adam added the type: bugstatus: acceptednetboxtopic: GraphQLseverity: low labels 2025-12-29 21:23:17 +01:00
adam closed this issue 2025-12-29 21:23:17 +01:00
Author
Owner

@jeffgdotorg commented on GitHub (Jun 12, 2024):

Thanks for reporting an unexpected behavior you've encountered in NetBox. While I was able to reproduce the behavior in the lab, the team consensus is that MAC addresses are not currently expected to be filterable in this way.

Please close this issue and open a new one using the feature request template, and using the Proposed functionality and Use case sections of that template to explain why this feature matters to you.

@jeffgdotorg commented on GitHub (Jun 12, 2024): Thanks for reporting an unexpected behavior you've encountered in NetBox. While I was able to reproduce the behavior in the lab, the team consensus is that MAC addresses are not currently expected to be filterable in this way. Please close this issue and open a new one using the [feature request template](https://github.com/netbox-community/netbox/issues/new?template=feature_request.md), and using the **Proposed functionality** and **Use case** sections of that template to explain why this feature matters to you.
Author
Owner

@cybarox commented on GitHub (Jun 13, 2024):

As already mentioned in #16261. We used this feature in versions prior to 4.0.x. The removal of this, perhaps unintended, feature is unfortunately a breaking change for us. With 3.7.6 the filtering of this field is possible with GraphQL.

@cybarox commented on GitHub (Jun 13, 2024): As already mentioned in #16261. We used this feature in versions prior to 4.0.x. The removal of this, perhaps unintended, feature is unfortunately a breaking change for us. With 3.7.6 the filtering of this field is possible with GraphQL.
Author
Owner

@jeffgdotorg commented on GitHub (Jun 13, 2024):

If you can demonstrate that this change represents a functional regression, I'm willing to reconsider the FR characterization. Please update your issue body as follows:

  • Open your Steps to reproduce with the assumption of a freshly installed system with an empty database
  • Include an example that illustrates that this worked, and the GraphQL query you used that got it to work, in a particular 3.7 release
  • Remove mention of the demo system, whose wide-open admin access and nightly resets make it an unreliable target for reporting bugs

I'm asking for these extra hoops not to discourage you, but to enable the very small team of maintainers to spend their time tracking down and fixing defects rather than interpolating aspects of the report that may seem obvious from your perspective.

@jeffgdotorg commented on GitHub (Jun 13, 2024): If you can demonstrate that this change represents a functional regression, I'm willing to reconsider the FR characterization. Please update your issue body as follows: - Open your **Steps to reproduce** with the assumption of a freshly installed system with an empty database - Include an example that illustrates that this worked, and the GraphQL query you used that got it to work, in a particular 3.7 release - Remove mention of the demo system, whose wide-open admin access and nightly resets make it an unreliable target for reporting bugs I'm asking for these extra hoops not to discourage you, but to enable the very small team of maintainers to spend their time tracking down and fixing defects rather than interpolating aspects of the report that may seem obvious from your perspective.
Author
Owner

@cybarox commented on GitHub (Jun 14, 2024):

@jeffgdotorg I've updated the issue above.

@cybarox commented on GitHub (Jun 14, 2024): @jeffgdotorg I've updated the issue above.
Author
Owner

@jeremypng commented on GitHub (Jan 23, 2025):

Fixed in my branch here:
https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign

fixed query:

query vendor_query($mac_vendor: String!, $facility_name: String!, $device_role: String!) {
  site_list(filters: {facility: {exact: $facility_name}}) {
    name
    devices(filters: {role: {slug: {exact: $device_role}}}) {
      name
      interfaces(filters: {mac_addresses: {mac_address: {i_contains: $mac_vendor}}}) {
        name
        mac_addresses {
          mac_address
        }
      }
    }
  }
}

results:

{
  "data": {
    "site_list": [
      {
        "name": "DM-Akron",
        "devices": [
          {
            "name": "dmi01-akron-rtr01",
            "interfaces": [
              {
                "name": "GigabitEthernet0/0/0",
                "mac_addresses": [
                  {
                    "mac_address": "DE:AD:BE:EF:00:69"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

If you'll assign this to me I'll tag it in my PR.

@jeremypng commented on GitHub (Jan 23, 2025): Fixed in my branch here: https://github.com/jeremypng/netbox/tree/refs/heads/graphql-filter-redesign fixed query: ```graphql query vendor_query($mac_vendor: String!, $facility_name: String!, $device_role: String!) { site_list(filters: {facility: {exact: $facility_name}}) { name devices(filters: {role: {slug: {exact: $device_role}}}) { name interfaces(filters: {mac_addresses: {mac_address: {i_contains: $mac_vendor}}}) { name mac_addresses { mac_address } } } } } ``` results: ```json { "data": { "site_list": [ { "name": "DM-Akron", "devices": [ { "name": "dmi01-akron-rtr01", "interfaces": [ { "name": "GigabitEthernet0/0/0", "mac_addresses": [ { "mac_address": "DE:AD:BE:EF:00:69" } ] } ] } ] } ] } } ``` If you'll assign this to me I'll tag it in my PR.
Author
Owner

@jeremystretch commented on GitHub (Feb 7, 2025):

Blocked by #7598

@jeremystretch commented on GitHub (Feb 7, 2025): Blocked by #7598
Author
Owner

@jeremystretch commented on GitHub (Mar 10, 2025):

I believe this has been resolved by the work on #7598. For example, the following will include all LAG interfaces for each device in the query:

{
  device_list {
    name
    interfaces(filters:{type:TYPE_LAG}) {
      name
    }
  }
}

This change will be implemented in NetBox v4.3.

@jeremystretch commented on GitHub (Mar 10, 2025): I believe this has been resolved by the work on #7598. For example, the following will include all LAG interfaces for each device in the query: ```graphql { device_list { name interfaces(filters:{type:TYPE_LAG}) { name } } } ``` This change will be implemented in NetBox v4.3.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9827