Type Error when setting MAX_PAGE_SIZE to None #5343

Closed
opened 2025-12-29 19:26:54 +01:00 by adam · 2 comments
Owner

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

NetBox version

v3.0.1

Python version

3.8

Steps to Reproduce

  1. Modify "netbox/netbox/configuration.py" and set MAX_PAGE_SIZE to None.
  2. Restart netbox service.
  3. Browse to a page that uses the "paginator". As an example: https://website.com/dcim/sites/

These steps result in a Type Error displayed in the browser.

Expected Behavior

The paginated URL should load normally. As an example "https://website.com/dcim/sites/" should load the DCIM's Sites in a table.

Observed Behavior

The URL fails to load normally, displaying the following message.

<class 'TypeError'>

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

Python version: 3.8.10
NetBox version: 3.0.1

I also enabled python INFO logging and it returns the following exception.

Internal Server Error: /dcim/sites/
Traceback (most recent call last):
  File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic.py", line 177, in get
    paginate_table(table, request)
  File "/opt/netbox/netbox/utilities/tables.py", line 408, in paginate_table
    'per_page': get_paginate_count(request)
  File "/opt/netbox/netbox/utilities/paginator.py", line 71, in get_paginate_count
    return min(per_page, settings.MAX_PAGE_SIZE)
TypeError: '<' not supported between instances of 'NoneType' and 'int'

The description for the MAX_PAGE_SIZE setting says "None" is an acceptable setting, but it no longer seems to be the case. Setting it to 0 fixes the error.

# An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g.
# "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request
# all objects by specifying "?limit=0".
Originally created by @cypher2048 on GitHub (Sep 8, 2021). ### NetBox version v3.0.1 ### Python version 3.8 ### Steps to Reproduce 1. Modify "netbox/netbox/configuration.py" and set MAX_PAGE_SIZE to None. 2. Restart netbox service. 3. Browse to a page that uses the "paginator". As an example: https://website.com/dcim/sites/ These steps result in a Type Error displayed in the browser. ### Expected Behavior The paginated URL should load normally. As an example "https://website.com/dcim/sites/" should load the DCIM's Sites in a table. ### Observed Behavior The URL fails to load normally, displaying the following message. ``` <class 'TypeError'> '<' not supported between instances of 'NoneType' and 'int' Python version: 3.8.10 NetBox version: 3.0.1 ``` I also enabled python INFO logging and it returns the following exception. ``` Internal Server Error: /dcim/sites/ Traceback (most recent call last): File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox-3.0.1/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic.py", line 177, in get paginate_table(table, request) File "/opt/netbox/netbox/utilities/tables.py", line 408, in paginate_table 'per_page': get_paginate_count(request) File "/opt/netbox/netbox/utilities/paginator.py", line 71, in get_paginate_count return min(per_page, settings.MAX_PAGE_SIZE) TypeError: '<' not supported between instances of 'NoneType' and 'int' ``` The description for the MAX_PAGE_SIZE setting says "None" is an acceptable setting, but it no longer seems to be the case. Setting it to 0 fixes the error. ``` # An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g. # "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request # all objects by specifying "?limit=0". ```
adam added the type: bugstatus: accepted labels 2025-12-29 19:26:54 +01:00
adam closed this issue 2025-12-29 19:26:54 +01:00
Author
Owner

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

Looks like this was just fixed under a related issue (#7209).

@jeremystretch commented on GitHub (Sep 8, 2021): Looks like this was just fixed under a related issue (#7209).
Author
Owner

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

I took a look at the commit that was related to the issue you referenced and it looks like using "None" would still throw the type error mentioned in this issue. Being allowed to use "None" and "0" is probably not necessary. All that may need to be done is to update the "netbox/netbox/configuration.example.py" config exmple and remove "None" as an option for the the MAX_PAGE_SIZE setting.

@cypher2048 commented on GitHub (Sep 8, 2021): I took a look at the commit that was related to the issue you referenced and it looks like using "None" would still throw the type error mentioned in this issue. Being allowed to use "None" and "0" is probably not necessary. All that may need to be done is to update the "netbox/netbox/configuration.example.py" config exmple and remove "None" as an option for the the MAX_PAGE_SIZE setting.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5343