Integer Custom Field shows maximum value when minimum value fails validation #10294

Closed
opened 2025-12-29 21:29:32 +01:00 by adam · 2 comments
Owner

Originally created by @costasd on GitHub (Sep 26, 2024).

Originally assigned to: @costasd on GitHub.

Deployment Type

Self-hosted

NetBox Version

version-agnostic, seeing it on latest and develop

Python Version

3.11

Steps to Reproduce

  1. Create a custom field of type Integer, with a minimum value, say 2 and a maximum value, say 1000. Attach it in one or more Object Types, doesn't matter, just need one.
  2. Go to that Object and try to save a value for the custom_field that is less than the minimum, say, 1. This will fail as expected, as it's less than the minimum expected.
  3. The raised Validation Exception if you do so via the API will be something like:
RequestError: The request failed with code 400 Bad Request: {'__all__': ["Invalid value for custom field 'example': Value must be at least 1000"]}

The above example is via pynetbox, but it doesn't matter, the Exception Message would be the same in all cases.

Expected Behavior

ValidationError's message should be Invalid value for custom field 'example': Value must be at least 2"

Observed Behavior

Instead, the exception message reports the validation_maximum instead of the validation_minimum. It's a tiny typo in the CustomField model validation code, latest develop:
85396866bc/netbox/extras/models/customfields.py (L662-L664)

Originally created by @costasd on GitHub (Sep 26, 2024). Originally assigned to: @costasd on GitHub. ### Deployment Type Self-hosted ### NetBox Version version-agnostic, seeing it on latest and develop ### Python Version 3.11 ### Steps to Reproduce 1. Create a custom field of type Integer, with a minimum value, say **2** and a maximum value, say **1000**. Attach it in one or more Object Types, doesn't matter, just need one. 2. Go to that Object and try to save a value for the custom_field that is less than the minimum, say, **1**. This will fail as expected, as it's less than the minimum expected. 3. The raised Validation Exception if you do so via the API will be something like: ``` RequestError: The request failed with code 400 Bad Request: {'__all__': ["Invalid value for custom field 'example': Value must be at least 1000"]} ``` The above example is via pynetbox, but it doesn't matter, the Exception Message would be the same in all cases. ### Expected Behavior ValidationError's message should be `Invalid value for custom field 'example': Value must be at least 2"` ### Observed Behavior Instead, the exception message reports the `validation_maximum` instead of the `validation_minimum`. It's a tiny typo in the CustomField model validation code, latest develop: https://github.com/netbox-community/netbox/blob/85396866bca8e1831f82be8ceb17a1e897dcaa69/netbox/extras/models/customfields.py#L662-L664
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:29:32 +01:00
adam closed this issue 2025-12-29 21:29:32 +01:00
Author
Owner

@costasd commented on GitHub (Sep 26, 2024):

👋 hi team and thanks. Happy to do a PR for this if you like.

@costasd commented on GitHub (Sep 26, 2024): :wave: hi team and thanks. Happy to do a PR for this if you like.
Author
Owner

@jeremystretch commented on GitHub (Sep 26, 2024):

Thanks @costasd, I've assigned this to you.

@jeremystretch commented on GitHub (Sep 26, 2024): Thanks @costasd, I've assigned this to you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10294