nautobot-app-data-validation-engine
nautobot-app-data-validation-engine copied to clipboard
Plugin reports all possible data validators as in use
Environment
- Python version:
- Nautobot version: 2.0 (next from 2023-05-31)
- nautobot-data-validation-engine version: branch
next-2.0
Expected Behavior
Plugin shows only model defined through DataComplianceRule
created in custom_validators.py
Observed Behavior
Plugin shows all models under Data Validators
Steps to Reproduce
- In plugin's
custom_validators.py
create following :
class DeviceDataComplianceRules(DataComplianceRule):
model = "dcim.device"
enforce = False
# Checks if a device name contains any special characters other than a dash (-), underscore (_), or period (.) using regex
def audit_device_name_chars(self):
if not re.match("^[a-zA-Z0-9\-_.]+$", self.context["object"].name):
raise ComplianceError({"name": "Device name contains unallowed special characters."})
# Checks if a device is not assigned to a rack
def audit_device_rack(self):
if not self.context["object"].rack:
raise ComplianceError({"rack": "Device should be assigned to a rack."})
def audit(self):
messages = {}
for fn in [self.audit_device_name_chars, self.audit_device_rack]:
try:
fn()
except ComplianceError as ex:
messages.update(ex.message_dict)
if messages:
raise ComplianceError(messages)
custom_validators = list(CustomValidatorIterator()) + [DeviceDataComplianceRules]
- Navigate to Installed Plugins -> , click on details
I could be wrong, but I think this is expected behavior and is just the inner workings of DVE. The Data Compliance feature was just added in v2.1.0 and this long list of data validators was still present in previous versions (i.e. I don't believe this is generated based on provided Data Compliance rules).
v2.1.0:
v2.0.1:
@lampwins - can you confirm that it's expected for DVE to show all models under Data Validators
?
@DistantVoyager The reported issue impacts all plugins.
If I create a custom plugin (other than the data validation plugin), and define a DataComplianceRule
within this plugin, it nautobot will report all data validators for this specific plugin.
This is an issue, as in an example given only dcim.device
should be data-validated.
@mzbroch - do I need to do anything with this issue you opened a while back? Or is it fine to close? Not sure if it was ever resolved among all the plugins, but maybe it's not crucial.
@mzbroch - do I need to do anything with this issue you opened a while back? Or is it fine to close? Not sure if it was ever resolved among all the plugins, but maybe it's not crucial.
So requires re-visiting, let's fix it and close.