REST API offset inconsistent with UI pagination #9095

Closed
opened 2025-12-29 20:45:22 +01:00 by adam · 1 comment
Owner

Originally created by @clickheretoday on GitHub (Jan 17, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v3.7.0

Python Version

3.11

Steps to Reproduce

  1. Fresh install NetBox 3.7.0
  2. Create sample contact Sample1
  3. Create sample contract role SampleRole1
  4. Create sample contract group SampleGroup1
  5. Import tenants from the file attached to get 350 Tenants
  6. Import contact assignments from the file attached to get 350 contact assignments
  7. Get http://localhost/api/tenancy/contact-assignments/
  8. Get http://localhost/api/tenancy/contact-assignments/?offset=100
  9. Get http://localhost/api/tenancy/contact-assignments/?limit=500

sample_tenants.csv
sample_contact assignments.csv

Expected Behavior

REST API returns the same result as ORM or GUI templates.

Observed Behavior

REST API doesn't return the contract assignment with ID 101 neither on page 3 (https://localhost/api/tenancy/contact-assignments/?offset=100) or any another paginated result (offset=50, 150, 200, 250, 300). The response on page 3 starts with ID 102.
The request http://localhost/api/tenancy/contact-assignments/?limit=500 returns results as expected.
The issue happens only when paginating results through the API.

Originally created by @clickheretoday on GitHub (Jan 17, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v3.7.0 ### Python Version 3.11 ### Steps to Reproduce 1. Fresh install NetBox 3.7.0 2. Create sample contact Sample1 3. Create sample contract role SampleRole1 4. Create sample contract group SampleGroup1 5. Import tenants from the file attached to get 350 Tenants 6. Import contact assignments from the file attached to get 350 contact assignments 8. Get http://localhost/api/tenancy/contact-assignments/ 9. Get http://localhost/api/tenancy/contact-assignments/?offset=100 10. Get http://localhost/api/tenancy/contact-assignments/?limit=500 [sample_tenants.csv](https://github.com/netbox-community/netbox/files/13962685/sample_tenants.csv) [sample_contact assignments.csv](https://github.com/netbox-community/netbox/files/13962686/sample_contact.assignments.csv) ### Expected Behavior REST API returns the same result as ORM or GUI templates. ### Observed Behavior REST API doesn't return the contract assignment with ID 101 neither on page 3 (https://localhost/api/tenancy/contact-assignments/?offset=100) or any another paginated result (offset=50, 150, 200, 250, 300). The response on page 3 starts with ID 102. The request http://localhost/api/tenancy/contact-assignments/?limit=500 returns results as expected. The issue happens only when paginating results through the API.
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 20:45:22 +01:00
adam closed this issue 2025-12-29 20:45:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 17, 2024):

I believe the root issue here is non-deterministic ordering due to ordering logic on the ContactAssignment model:

    class Meta:
        ordering = ('priority', 'contact')

In scenarios where there are multiple assignments for the same contact with the same priority, ordering is not specified.

@jeremystretch commented on GitHub (Jan 17, 2024): I believe the root issue here is non-deterministic ordering due to ordering logic on the ContactAssignment model: ```python class Meta: ordering = ('priority', 'contact') ``` In scenarios where there are multiple assignments for the same contact with the same priority, ordering is not specified.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9095