Skip to content

Commit bc26529

Browse files
committed
Fixes #21049: Remove stale custom field data during object validation
1 parent da64c56 commit bc26529

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

netbox/netbox/models/features.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,13 @@ def clean(self):
288288
cf.name: cf for cf in CustomField.objects.get_for_model(self)
289289
}
290290

291+
# Remove any stale custom field data
292+
self.custom_field_data = {
293+
k: v for k, v in self.custom_field_data.items() if k in custom_fields.keys()
294+
}
295+
291296
# Validate all field values
292297
for field_name, value in self.custom_field_data.items():
293-
if field_name not in custom_fields:
294-
raise ValidationError(_("Unknown field name '{name}' in custom field data.").format(
295-
name=field_name
296-
))
297298
try:
298299
custom_fields[field_name].validate(value)
299300
except ValidationError as e:

0 commit comments

Comments
 (0)