Skip to content

Commit 5aac99c

Browse files
authored
Validate inet attributes are not multi attributes (#410)
* Validate inet attributes are not multi attributes Ensure nobody create multi attribute of type inet. This is currently not supported and will cause crashes during runtime in the query executer.
1 parent d6c420d commit 5aac99c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

serveradmin/serverdb/forms.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ class Meta:
4141
fields = '__all__'
4242

4343
def clean(self):
44-
if self.cleaned_data['type'] != 'relation' and self.cleaned_data['target_servertype'] is not None:
44+
attr_type = self.cleaned_data.get('type') or self.instance.type # New or existing attribute ?
45+
46+
if attr_type != 'relation' and self.cleaned_data.get('target_servertype') is not None:
4547
raise ValidationError('Attribute type must be relation when target servertype is selected!')
48+
49+
if attr_type == 'inet' and self.cleaned_data.get('multi') is True:
50+
raise ValidationError('Multi attributes of type inet are not supported!')
51+
4652
super().clean()

0 commit comments

Comments
 (0)