Skip to content
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

GraphQL: NOT-Filter (here for tenants_list) not honored for group(_id) and results includes the filtered group #18163

Closed
dxks opened this issue Dec 5, 2024 · 2 comments
Labels
status: duplicate This issue has already been raised type: bug A confirmed report of unexpected behavior in the application

Comments

@dxks
Copy link
Contributor

dxks commented Dec 5, 2024

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.7

Python Version

3.12

Steps to Reproduce

All verified on demo.netbox.dev (so assumption is that Tenant-Group Customers exists)

  1. Create a new Tenant-Group (i.e. Partners)
  2. Create a new Tenant and make it a member of Partners

Fire the folling graphql query:

query MyQuery {
  tenant_list(filters:{NOT:{group:"customers"}}) {
    id
    name
    group {
      id
      name
      slug
    }
  }
}

Expected Behavior

Getting a list of all Tenants that are not member of the group Customers:

{
  "data": {
    "tenant_list": [
      {
        "id": "15",
        "name": "NetBoxLabs",
        "group": {
          "id": "2",
          "name": "Partners",
          "slug": "partners"
        }
      }
    ]
  }
}

Observed Behavior

Getting a list of all Tenants that are member of the group Customers:

{
  "data": {
    "tenant_list": [
      {
        "id": "7",
        "name": "Cyberdyne Systems",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "5",
        "name": "Dunder-Mifflin, Inc.",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "1",
        "name": "Initech",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "10",
        "name": "Jimbob's Banking & Trust",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "13",
        "name": "NC State University",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "9",
        "name": "Nakatomi Corportation",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "3",
        "name": "Pied Piper",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "4",
        "name": "Stark Industries",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "2",
        "name": "Strickland Propane",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "8",
        "name": "Umbrella Corporation",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      },
      {
        "id": "6",
        "name": "Wayne Enterprises",
        "group": {
          "id": "1",
          "name": "Customers",
          "slug": "customers"
        }
      }
    ]
  }
}
@dxks dxks added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Dec 5, 2024
@dxks
Copy link
Contributor Author

dxks commented Dec 5, 2024

Looks like OR also not working:

query MyQuery {
  tenant_list(filters:{group:"customers", OR:{group:"partners"}}) {
    id
    name
    group {
      id
      name
      slug
    }
  }
}

brings an empty list:

{
  "data": {
    "tenant_list": []
  }
}

so only the last group value is used for filtering

@arthanson arthanson added status: duplicate This issue has already been raised and removed status: needs triage This issue is awaiting triage by a maintainer labels Dec 5, 2024
@arthanson
Copy link
Collaborator

Closing as a dupe of #17688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate This issue has already been raised type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants