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

filter present_in_vrf_id returning more results than expected #17362

Closed
pl0xym0r opened this issue Sep 4, 2024 · 5 comments · Fixed by #17376
Closed

filter present_in_vrf_id returning more results than expected #17362

pl0xym0r opened this issue Sep 4, 2024 · 5 comments · Fixed by #17376
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@pl0xym0r
Copy link
Contributor

pl0xym0r commented Sep 4, 2024

Deployment Type

Self-hosted

NetBox Version

v4.0.10

Python Version

3.11

Steps to Reproduce

1 Use the data from https://github.com/netbox-community/netbox-demo-data
2 Add prefix in VRF shared
3 Use ipam/prefixes/?present_in_vrf_id=5 (echo VRF) to have all prefixes from Shared and Echo VRF

Expected Behavior

A display of all prefixes seen from Echo VRF point of view

Observed Behavior

All prefixes from Echo VRF are displayed twice
It seems the union of querysets returns twice the value of the VRF in parameter :

def filter_present_in_vrf(self, queryset, name, vrf):

image

tested into nbshell itself :

echo=VRF.objects.get(id=5)
queryset=VRF.objects.all()
queryset.filter(Q(id=5))
<RestrictedQuerySet [<VRF: Echo (65000:500)>]>
queryset.filter(Q(export_targets__in=echo.import_targets.all()))
<RestrictedQuerySet [<VRF: Shared (65000:1)>]>
queryset.filter(Q(id=5) |Q(export_targets__in=echo.import_targets.all()))
<RestrictedQuerySet [<VRF: Echo (65000:500)>, <VRF: Echo (65000:500)>, <VRF: Shared (65000:1)>]>

I found a kind of explanation on stackoverflow : https://stackoverflow.com/questions/4411049/how-can-i-find-the-union-of-two-django-querysets

Would the .distinct() method answer my issue?

@pl0xym0r pl0xym0r added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Sep 4, 2024
@arthanson
Copy link
Collaborator

@pl0xym0r Can you please expand on your reproduction steps - where is "VRF shared", can you please detail which menu item you are going to, also I'm not seeing where you are getting Shared and Echo from.

@arthanson arthanson added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Sep 4, 2024
@arthanson arthanson self-assigned this Sep 4, 2024
@pl0xym0r
Copy link
Contributor Author

pl0xym0r commented Sep 4, 2024

All the data come from the demo-data

Even netbox demo has the issue:
1 go to prefix
2 filter : present_in_vrf select echo
image

Filter on delta VRF, same behavior:
image

All prefixes in VRF selected are shown twice (not expected), from VRF RT imported once as expected

@jeremystretch jeremystretch changed the title filter_present_in_vrf returning more results than expected filter present_in_vrf_id returning more results than expected Sep 4, 2024
@arthanson arthanson removed their assignment Sep 4, 2024
@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: revisions needed This issue requires additional information to be actionable labels Sep 4, 2024
@pl0xym0r
Copy link
Contributor Author

pl0xym0r commented Sep 4, 2024

if needed, I can update the functions. Idk if the same behavior is on IPAddressFilterSet as the same function exists. I'd like to update both

@arthanson
Copy link
Collaborator

@pl0xym0r I'll assign to you then.

@arthanson arthanson 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 Sep 4, 2024
@pl0xym0r
Copy link
Contributor Author

pl0xym0r commented Sep 4, 2024

same issue for ip-addresses:
image

pl0xym0r added a commit to pl0xym0r/netbox that referenced this issue Sep 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available 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.

2 participants