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

Custom Validation does not work for DataSource #14349

Closed
amyasnikov opened this issue Nov 25, 2023 · 1 comment · Fixed by #14368
Closed

Custom Validation does not work for DataSource #14349

amyasnikov opened this issue Nov 25, 2023 · 1 comment · Fixed by #14368
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

@amyasnikov
Copy link
Contributor

NetBox version

v3.6.5

Python version

3.10

Steps to Reproduce

  1. Add this snippet to your configuration.py
from extras.validators import CustomValidator

class MyValidator(CustomValidator):
    def validate(self, instance):
        self.fail("This error won't appear")

CUSTOM_VALIDATORS = {"core.datasource": [MyValidator]}
  1. Make sure that when you create Data Source from UI there is no validation error

This happens due to lack of super().clean() here:
https://github.com/netbox-community/netbox/blob/develop/netbox/core/models/data.py#L124

And, I suppose, it also causes other unpleasant side-effects because other NetBoxFeatureSet members .clean() are also not called

Expected Behavior

Validation Error happens after creation of the new Data Source after MyValidator has been added to CUSTOM_VALIDATORS

Observed Behavior

MyValidator is ignored, no error appeared.

@amyasnikov amyasnikov added the type: bug A confirmed report of unexpected behavior in the application label Nov 25, 2023
@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Nov 27, 2023
@jeremystretch
Copy link
Member

@amyasnikov thanks for taking the time to track this down and report it!

@jeremystretch jeremystretch self-assigned this Nov 28, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Nov 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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