API calls not respecting limit paramater when set to 0 #5339

Closed
opened 2025-12-29 19:26:52 +01:00 by adam · 1 comment
Owner

Originally created by @shanerenshawaus on GitHub (Sep 8, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.1

Python version

3.9

Steps to Reproduce

  1. Set MAX_PAGE_SIZE=0
  2. ensure you have an object type that has enough entries to reproduce
  3. make an api call that has the limit=0 flag eg https://netbox/api/dcim/devices/?limit=0

Expected Behavior

The API should return all objects from the query with no next value eg:

GET /api/dcim/devices/?limit=10000

HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 6672,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 2902,
            ....
       } ,
      ...
   ]
}

Note, the limit above was used to simulate what is expected to respond.

Observed Behavior

The API returns the result with the default pagination (50 for us):

GET /api/dcim/devices/?limit=0

HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 6672,
    "next": "https://netbox/api/dcim/devices/?limit=50&offset=50",
    "previous": null,
    "results": [
        {
            "id": 2902,
            ....
       } ,
      ...
   ]
}

Setting the limit paramater to any other value returns succesfully, eg if we set it to 10,000 it will return all 6672 objects

Originally created by @shanerenshawaus on GitHub (Sep 8, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.1 ### Python version 3.9 ### Steps to Reproduce 1. Set MAX_PAGE_SIZE=0 2. ensure you have an object type that has enough entries to reproduce 2. make an api call that has the limit=0 flag eg https://netbox/api/dcim/devices/?limit=0 ### Expected Behavior The API should return all objects from the query with no next value eg: ``` GET /api/dcim/devices/?limit=10000 HTTP 200 OK Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "count": 6672, "next": null, "previous": null, "results": [ { "id": 2902, .... } , ... ] } ``` Note, the limit above was used to simulate what is expected to respond. ### Observed Behavior The API returns the result with the default pagination (50 for us): ``` GET /api/dcim/devices/?limit=0 HTTP 200 OK Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "count": 6672, "next": "https://netbox/api/dcim/devices/?limit=50&offset=50", "previous": null, "results": [ { "id": 2902, .... } , ... ] } ``` Setting the limit paramater to any other value returns succesfully, eg if we set it to 10,000 it will return all 6672 objects
adam added the type: bugstatus: accepted labels 2025-12-29 19:26:52 +01:00
adam closed this issue 2025-12-29 19:26:52 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 8, 2021):

Related to #7101

@jeremystretch commented on GitHub (Sep 8, 2021): Related to #7101
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5339