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 returns all objects if tag doesn't exist #11473

Closed
4xoc opened this issue Jan 12, 2023 · 4 comments · Fixed by #11755
Closed

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

4xoc opened this issue Jan 12, 2023 · 4 comments · Fixed by #11755
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@4xoc
Copy link

4xoc commented Jan 12, 2023

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" } ] } ] } }

@4xoc 4xoc added the type: bug A confirmed report of unexpected behavior in the application label Jan 12, 2023
@jeremystretch jeremystretch added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Jan 12, 2023
@aronbergurj99
Copy link
Contributor

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.

aronbergurj99 pushed a commit to aronbergurj99/netbox that referenced this issue Feb 14, 2023
@aronbergurj99
Copy link
Contributor

@jeremystretch can you assign this to me?

@kkthxbye-code kkthxbye-code added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Feb 15, 2023
@kkthxbye-code
Copy link
Contributor

@aronbj20 - I've assigned it to you.

@4xoc
Copy link
Author

4xoc commented Feb 16, 2023

Thanks for fixing this

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants