From bc26529be86d2849173765fa74360089d6cb2e8e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 5 Jan 2026 09:49:32 -0500 Subject: [PATCH] Fixes #21049: Remove stale custom field data during object validation --- netbox/netbox/models/features.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index e0d03d6e7..653dc50c8 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -288,12 +288,13 @@ class CustomFieldsMixin(models.Model): cf.name: cf for cf in CustomField.objects.get_for_model(self) } + # Remove any stale custom field data + self.custom_field_data = { + k: v for k, v in self.custom_field_data.items() if k in custom_fields.keys() + } + # Validate all field values for field_name, value in self.custom_field_data.items(): - if field_name not in custom_fields: - raise ValidationError(_("Unknown field name '{name}' in custom field data.").format( - name=field_name - )) try: custom_fields[field_name].validate(value) except ValidationError as e: