GraphQL returns all objects if tag doesn't exist #7500

Closed
opened 2025-12-29 20:24:18 +01:00 by adam · 4 comments
Owner

Originally created by @4xoc on GitHub (Jan 12, 2023).

Originally assigned to: @aronjohanns on GitHub.

NetBox version

v3.4.2

Python version

3.10

Steps to Reproduce

  1. query GraphQL for device/interface with a tag that doesn't exist

Expected Behavior

Resulting list of devices/interfaces only contains devices matching the tags or none if no device exists with matching tags.

Observed Behavior

All devices/interfaces are returned no matter what tag filter has been applied. Same seems to apply for all kinds of filters that can be defined in GraphQL. No errors are returned.

Example below

query:
{ device_list(tag: "blablalba") { id name tags { name } } interface_list(tag: "not-ipmi_exporter") { id device { id } tags { name } } }

result:
{ "data": { "device_list": [ { "id": "1", "name": "device-A", "tags": [ { "name": "node_exporter" } ] }, { "id": "2", "name": "device-B", "tags": [ { "name": "node_exporter" } ] } ], "interface_list": [ { "id": "1", "device": { "id": "1" }, "tags": [ { "name": "ipmi_exporter" } ] }, { "id": "2", "device": { "id": "2" }, "tags": [ { "name": "ipmi_exporter" } ] } ] } }

Originally created by @4xoc on GitHub (Jan 12, 2023). Originally assigned to: @aronjohanns on GitHub. ### NetBox version v3.4.2 ### Python version 3.10 ### Steps to Reproduce 1. query GraphQL for device/interface with a tag that doesn't exist ### Expected Behavior Resulting list of devices/interfaces only contains devices matching the tags or none if no device exists with matching tags. ### Observed Behavior All devices/interfaces are returned no matter what tag filter has been applied. Same seems to apply for all kinds of filters that can be defined in GraphQL. No errors are returned. Example below query: `{ device_list(tag: "blablalba") { id name tags { name } } interface_list(tag: "not-ipmi_exporter") { id device { id } tags { name } } } ` result: `{ "data": { "device_list": [ { "id": "1", "name": "device-A", "tags": [ { "name": "node_exporter" } ] }, { "id": "2", "name": "device-B", "tags": [ { "name": "node_exporter" } ] } ], "interface_list": [ { "id": "1", "device": { "id": "1" }, "tags": [ { "name": "ipmi_exporter" } ] }, { "id": "2", "device": { "id": "2" }, "tags": [ { "name": "ipmi_exporter" } ] } ] } }`
adam added the type: bugstatus: accepted labels 2025-12-29 20:24:18 +01:00
adam closed this issue 2025-12-29 20:24:18 +01:00
Author
Owner

@aronjohanns commented on GitHub (Feb 14, 2023):

I think this could be solved by checking if the filterset is valid in ObjectListField.list_resolver() static method and returning an empty queryset if not valid.

I can take a look at this.

@aronjohanns commented on GitHub (Feb 14, 2023): I think this could be solved by checking if the filterset is valid in ObjectListField.list_resolver() static method and returning an empty queryset if not valid. I can take a look at this.
Author
Owner

@aronjohanns commented on GitHub (Feb 15, 2023):

@jeremystretch can you assign this to me?

@aronjohanns commented on GitHub (Feb 15, 2023): @jeremystretch can you assign this to me?
Author
Owner

@kkthxbye-code commented on GitHub (Feb 15, 2023):

@aronbj20 - I've assigned it to you.

@kkthxbye-code commented on GitHub (Feb 15, 2023): @aronbj20 - I've assigned it to you.
Author
Owner

@4xoc commented on GitHub (Feb 16, 2023):

Thanks for fixing this

@4xoc commented on GitHub (Feb 16, 2023): Thanks for fixing this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7500