GraphQL filter not honoring NOT operator when trying to exclude tags. #9837

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

Originally created by @Kurnugia on GitHub (Jun 12, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.5

Python Version

3.10

Steps to Reproduce

  1. Create a Tag called Excluded.
  2. Assign the tag to a Prefix.
  3. Open GraphiQL and execute the following query:
{
  inclusive: prefix_list(filters: {
    tag: "excluded"
  }) {
    prefix
    tags {
      name
      slug
    }
  }
  
  exclusive: prefix_list(filters: {
    NOT: {tag: "excluded"}
  }) {
    prefix
    tags {
      name
      slug
    }
  }
}
  1. View Results.

Expected Behavior

When the query is executed, the inclusive section of the query should return all prefixes that match this tag.

When the query is executed, the exclusive section of the query should return all prefixes that do not match this tag.

Observed Behavior

When executed, the same data is returned, as though the NOT clause is being ignored.

I also applied the tag to a Device and the same behavior is exhibited.

GQL Filter Issue

Originally created by @Kurnugia on GitHub (Jun 12, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.5 ### Python Version 3.10 ### Steps to Reproduce 1. Create a **Tag** called **Excluded**. 2. Assign the tag to a **Prefix**. 3. Open GraphiQL and execute the following query: ```no-highlight { inclusive: prefix_list(filters: { tag: "excluded" }) { prefix tags { name slug } } exclusive: prefix_list(filters: { NOT: {tag: "excluded"} }) { prefix tags { name slug } } } ``` 4. View Results. ### Expected Behavior When the query is executed, the ***inclusive*** section of the query should return all prefixes that match this tag. When the query is executed, the ***exclusive*** section of the query should return all prefixes that **do not** match this tag. ### Observed Behavior When executed, the same data is returned, as though the NOT clause is being ignored. I also applied the tag to a **Device** and the same behavior is exhibited. ![GQL Filter Issue](https://github.com/netbox-community/netbox/assets/62632794/dc5bef91-5848-4e1b-88a7-0979c04d6629)
adam added the type: bugstatus: duplicate labels 2025-12-29 21:23:24 +01:00
adam closed this issue 2025-12-29 21:23:24 +01:00
Author
Owner

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

Closing as dupe of #16024

@arthanson commented on GitHub (Jun 13, 2024): Closing as dupe of #16024
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9837