netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.61k stars 2.53k forks source link

Missing lookup filters for interface object fields #16511

Open cybarox opened 2 months ago

cybarox commented 2 months ago

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"
                  }
                ]
              }
            ]
          }
        ]
      }
    }
jeffgdotorg commented 2 months ago

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.

cybarox commented 2 months ago

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.

jeffgdotorg commented 2 months ago

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:

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.

cybarox commented 2 months ago

@jeffgdotorg I've updated the issue above.