Skip to content

fix: paginated list requests silently skipping rows - #543

Merged
semx merged 1 commit into
bb-Ricardo:developmentfrom
marcinpsk:fix/paginated-list-ordering
Sep 7, 2026
Merged

semx merged 1 commit into
bb-Ricardo:developmentfrom
marcinpsk:fix/paginated-list-ordering

Conversation

@marcinpsk

Copy link
Copy Markdown

NetBox paginates list endpoints with limit/offset, and several models order by a key that is not unique. Rows that tie on the sort key have no defined position between two queries, so walking the pages can return one tied row twice and never return another.

verified against Netbox, as I was having missing/duplicated rows without it - my sample was around 1200 rows, on average 5-7 were having issue every time.

List requests now ask for ordering=id. The primary key is unique, so the sort is total and every row is walked exactly once.

Added same [tool.pytest.ini_options] to pyproject.toml as in #541 - so it can drop out.

NetBox paginates list endpoints with limit/offset, and several models order by a
key that is not unique. Rows that tie on the sort key have no defined position
between two queries, so walking the pages can return one tied row twice and never
return another.

A row that is never returned looks absent to the sync, which then creates a second
copy of an object that already exists. Each new duplicate adds another tie, so the
problem feeds itself. ipam.ipaddress is one example: it orders by address, and the
same address can legitimately be present more than once.

Measured against a list endpoint holding 1222 rows tied on their sort key, read
with a 200 row page size: 5 to 7 rows were missed on every full walk, reproducibly.

List requests now ask for ordering=id. The primary key is unique, so the sort is
total and every row is walked exactly once. A caller that needs a specific order
still gets it, and single object requests are untouched. Verified against the
NetBox REST API: 5 rows missed without the parameter, none with it.

The tests drive the real request() pagination loop against an HTTP server that
reproduces the tie instability. The ordering assertions cover every page, not only
the first request, so an ordering dropped from the pagination link is caught.
@jamespage001

Copy link
Copy Markdown

We independently hit the same issue while validating netbox-sync v1.8.1 against an existing VMware / NetBox environment (~579 VMs, NetBox 4.2.x).

We saw pagination behaving inconsistently during repeated runs and arrived at the same mitigation: adding explicit ordering=id to make traversal stable.

I included this as item 5 in #537 before seeing this PR, so it’s reassuring to see the same behaviour reproduced independently.

Happy to provide sanitized logs or details from our testing if useful.

@marcinpsk

marcinpsk commented Sep 4, 2026

Copy link
Copy Markdown
Author

Hi @jamespage001
I've missed that issue - but I saw point 4 as well that you mention - and that is against redfish only.

@semx
semx merged commit ce6182e into bb-Ricardo:development Sep 7, 2026
@semx

semx commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks. Verified against the vcsim suite: the added ordering=id on unscoped list walks makes the sort total, so paginated reads no longer repeat or skip rows on a tied default ordering. Full suite green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants