nautobot-app-data-validation-engine
nautobot-app-data-validation-engine copied to clipboard
Support validating the set of tags on an object
Environment
- Python version: 3.8.5
- Nautobot version: 1.0.1
- nautobot-plugin-data-validation-engine: 1.0.0-dev
Steps to Reproduce
- Create regex rule for Object allowing tags, e.g. ipam.VLAN
- Specify "tags" as the Field
- Specify simple regex e.g. "data" as Regular expression
Example rule used for testing:
Expected Behavior
One of two outcomes should happend:
- When new VLAN is created and tag matching regex is added new object should be created without errors.
- When new VLAN is created and added tag does NOT match regex a validation error should be raised.
Observed Behavior
TypeError is raised: "expected string or bytes-like object"
Full traceback:
Internal Server Error: /ipam/vlans/add/
Traceback (most recent call last):
File "/opt/nautobot/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/nautobot/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/nautobot/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/nautobot/lib/python3.8/site-packages/nautobot/core/views/generic.py", line 266, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/opt/nautobot/lib/python3.8/site-packages/nautobot/utilities/views.py", line 94, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/opt/nautobot/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/opt/nautobot/lib/python3.8/site-packages/nautobot/core/views/generic.py", line 293, in post
if form.is_valid():
File "/opt/nautobot/lib/python3.8/site-packages/django/forms/forms.py", line 177, in is_valid
return self.is_bound and not self.errors
File "/opt/nautobot/lib/python3.8/site-packages/django/forms/forms.py", line 172, in errors
self.full_clean()
File "/opt/nautobot/lib/python3.8/site-packages/django/forms/forms.py", line 376, in full_clean
self._post_clean()
File "/opt/nautobot/lib/python3.8/site-packages/django/forms/models.py", line 405, in _post_clean
self.instance.full_clean(exclude=exclude, validate_unique=False)
File "/opt/nautobot/lib/python3.8/site-packages/django/db/models/base.py", line 1216, in full_clean
self.clean()
File "/opt/nautobot/lib/python3.8/site-packages/nautobot/extras/plugins/validators.py", line 34, in wrapper
custom_validator(model_instance).clean()
File "/opt/nautobot/lib/python3.8/site-packages/nautobot_data_validation_engine/custom_validators.py", line 35, in clean
if not re.match(rule.regular_expression, getattr(obj, rule.field)):
File "/usr/lib/python3.8/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object