Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
costasd opened this issue Sep 26, 2024 · 2 comments · Fixed by #17622
Closed

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

costasd opened this issue Sep 26, 2024 · 2 comments · Fixed by #17622
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@costasd
Copy link
Contributor

costasd commented Sep 26, 2024

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:

if self.validation_minimum is not None and value < self.validation_minimum:
raise ValidationError(
_("Value must be at least {minimum}").format(minimum=self.validation_maximum)

@costasd costasd added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Sep 26, 2024
@costasd
Copy link
Contributor Author

costasd commented Sep 26, 2024

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

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Sep 26, 2024
@jeremystretch
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants