-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Netbox API returns duplicate resources during paging with offset #18729
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
Comments
This seems fairly high severity as the API pagination ought to be predictable and orderly. Is this reproducible in any other models? |
In our local environment, we can reproduce this with the IPAddress model. This is where we initially found it but we have not been able to reproduce it on the public Netbox instance so we held back from raising the issue. We thought it was because we have 500,000 IPAddresses in netbox across various VRFs that this was causing the duplicates. But even then the duplicates were not severe. Fetching with limit=1000 (so 500 pages) we were getting only about 10 duplicates. Still very problematic for our code and we had to write methods to recover from this, but luckily on this model the issue is severe and should lead to the quicker discovery of the problem. Its possible we are doing something wrong, but either way knowing how to fix would really help us. |
I have seen this issue as well, when performing GET requests for Services. |
It looks like the issue is just that Django isn't obeying the model's netbox/netbox/virtualization/api/views.py Lines 37 to 41 in 913405a
Note that
If https://code.djangoproject.com/ticket/32811 We may need to identify all the ViewSets that use annotation in this way and add explicit ordering to the queryset statement. |
Uh oh!
There was an error while loading. Please reload this page.
Deployment Type
Self-hosted
NetBox Version
v4.2.3
Python Version
3.12
Steps to Reproduce
Use Python or Postman API to GET the clusters from Netbox by paging through the resources.
The real-world use case is to load a larger list of clusters using the paging mechanism.
To reproduce Run the following code
To Reproduce in Postman:
Issue the GET requests with following path:
https://demo.netbox.dev/api/virtualization/clusters/?limit=5&offset=5
and then issue again with
https://demo.netbox.dev/api/virtualization/clusters/?limit=5&offset=30
You will see that Cluster with ID 10 repeats in two responses. The ID might differ at times.
The Example above uses demo.netbox.dev, but the same behavior we experience on our on-prem self-hosted instance. With 150 clusters we see about 30-35 duplicates.
Expected Behavior
Expect not to have duplicates returned as we page through the clusters.
Observed Behavior
Clusters with duplicate IDs are present in the responses.
We see that few IDs are duplicated in the response
The text was updated successfully, but these errors were encountered: