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

REST API offset inconsistent with UI pagination #14816

Closed
clickheretoday opened this issue Jan 17, 2024 · 1 comment · Fixed by #14822
Closed

REST API offset inconsistent with UI pagination #14816

clickheretoday opened this issue Jan 17, 2024 · 1 comment · Fixed by #14822
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@clickheretoday
Copy link

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.

@clickheretoday clickheretoday added the type: bug A confirmed report of unexpected behavior in the application label Jan 17, 2024
@jeremystretch
Copy link
Member

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 jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows labels Jan 17, 2024
@jeremystretch jeremystretch self-assigned this Jan 17, 2024
@jeremystretch jeremystretch 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 Jan 17, 2024
@jeffgdotorg jeffgdotorg changed the title REST API offset issue REST API offset inconsistent with UI pagination Feb 4, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows 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