Skip to content

Missing lookup filters for interface object fields #16511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cybarox opened this issue Jun 11, 2024 · 7 comments
Closed

Missing lookup filters for interface object fields #16511

cybarox opened this issue Jun 11, 2024 · 7 comments
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: GraphQL type: bug A confirmed report of unexpected behavior in the application
Milestone

Comments

@cybarox
Copy link
Contributor

cybarox commented 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"
                  }
                ]
              }
            ]
          }
        ]
      }
    }
@cybarox cybarox added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Jun 11, 2024
@jeffgdotorg
Copy link
Contributor

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 jeffgdotorg removed type: bug A confirmed report of unexpected behavior in the application status: needs triage This issue is awaiting triage by a maintainer labels Jun 12, 2024
@jeffgdotorg jeffgdotorg removed their assignment Jun 12, 2024
@cybarox
Copy link
Contributor Author

cybarox commented 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.

@jeffgdotorg jeffgdotorg added status: under review Further discussion is needed to determine this issue's scope and/or implementation type: bug A confirmed report of unexpected behavior in the application labels Jun 13, 2024
@jeffgdotorg
Copy link
Contributor

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.

@cybarox
Copy link
Contributor Author

cybarox commented Jun 14, 2024

@jeffgdotorg I've updated the issue above.

@netbox-community netbox-community deleted a comment from cybarox Jul 4, 2024
@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Aug 13, 2024
@arthanson arthanson added the severity: low Does not significantly disrupt application functionality, or a workaround is available label Sep 5, 2024
@jeremystretch jeremystretch added the netbox label Nov 1, 2024 — with Linear
@jeremypng
Copy link

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.

@jeremystretch jeremystretch added status: blocked Another issue or external requirement is preventing implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Feb 7, 2025
@jeremystretch
Copy link
Member

Blocked by #7598

@jeremystretch
Copy link
Member

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 jeremystretch removed the status: blocked Another issue or external requirement is preventing implementation label Mar 10, 2025
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Mar 10, 2025
@jeremystretch jeremystretch added this to the v4.3 milestone Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation topic: GraphQL type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

5 participants