Clearing page length user preference breaks pagination #9692

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

Originally created by @devon-mar on GitHub (May 17, 2024).

Originally assigned to: @devon-mar on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.0.2

Python Version

3.10

Steps to Reproduce

  1. Create a new user account
  2. Visit a page that uses pagination. It should load properly.
  3. Open /user/preferences/ and click the "X" on Page length.
  4. Click Save.
  5. Visit the page in step 2. An error should occur.

Expected Behavior

The page should load without an error.

Observed Behavior

<class 'TypeError'>

'<' not supported between instances of 'int' and 'str'

Python version: 3.10.14
NetBox version: 4.0.2
Plugins: 
  netbox_demo: 0.5.0

I believe this is because the paginate.per_page preference is an empty string:

GET /api/users/config/

{
    "ui": {
        "htmx_navigation": ""
    },
    "locale": {
        "language": ""
    },
    "pagination": {
        "per_page": "",
        "placement": "bottom"
    },
    "data_format": "json"
}

Therefore, per_page is set to "" instead of config.PAGINATE_COUNT:
4b2f26a800/netbox/utilities/paginator.py (L90)

Originally created by @devon-mar on GitHub (May 17, 2024). Originally assigned to: @devon-mar on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.0.2 ### Python Version 3.10 ### Steps to Reproduce 1. Create a new user account 2. Visit a page that uses pagination. It should load properly. 3. Open `/user/preferences/` and click the "X" on `Page length`. 4. Click `Save`. 5. Visit the page in step 2. An error should occur. ### Expected Behavior The page should load without an error. ### Observed Behavior ``` <class 'TypeError'> '<' not supported between instances of 'int' and 'str' Python version: 3.10.14 NetBox version: 4.0.2 Plugins: netbox_demo: 0.5.0 ``` I believe this is because the `paginate.per_page` preference is an empty string: ``` GET /api/users/config/ { "ui": { "htmx_navigation": "" }, "locale": { "language": "" }, "pagination": { "per_page": "", "placement": "bottom" }, "data_format": "json" } ``` Therefore, `per_page` is set to `""` instead of `config.PAGINATE_COUNT`: https://github.com/netbox-community/netbox/blob/4b2f26a8002a8f01e186211c648768892cc199c8/netbox/utilities/paginator.py#L90
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 21:20:59 +01:00
adam closed this issue 2025-12-29 21:21:00 +01:00
Author
Owner

@devon-mar commented on GitHub (May 17, 2024):

Can I be assigned to this? I have a PR ready to go.

@devon-mar commented on GitHub (May 17, 2024): Can I be assigned to this? I have a PR ready to go.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9692