fix(wireless): Add null checks for WirelessLink interface validation

Adds checks for the presence of `interface_a` and `interface_b` to avoid
attribute errors during WirelessLink validation. Ensures robust handling
of edge cases where the attributes may be missing.
This commit is contained in:
Martin Hauser 2025-06-11 16:07:12 +02:00
parent a021d29280
commit 5114424d88
No known key found for this signature in database

View File

@ -198,13 +198,13 @@ class WirelessLink(WirelessAuthenticationBase, DistanceMixin, PrimaryModel):
super().clean()
# Validate interface types
if self.interface_a.type not in WIRELESS_IFACE_TYPES:
if hasattr(self, "interface_a") and self.interface_a.type not in WIRELESS_IFACE_TYPES:
raise ValidationError({
'interface_a': _(
"{type} is not a wireless interface."
).format(type=self.interface_a.get_type_display())
})
if self.interface_b.type not in WIRELESS_IFACE_TYPES:
if hasattr(self, "interface_b") and self.interface_b.type not in WIRELESS_IFACE_TYPES:
raise ValidationError({
'interface_b': _(
"{type} is not a wireless interface."