From 3fdff33e2e6966d7f963618f4e57ffd5b3bddad1 Mon Sep 17 00:00:00 2001 From: IluaAir Date: Tue, 24 Feb 2026 22:28:36 +0300 Subject: [PATCH] Implement validation for optional VLANs in BaseDevice - Added a check in the BaseDevice class to raise a ValueError if the 'vlans' section is declared in the template but not present in the raw data returned by TTP. - This enhancement improves data integrity by ensuring that optional groups are properly validated before processing. --- oxi/interfaces/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oxi/interfaces/base.py b/oxi/interfaces/base.py index 4077b92..bdd4308 100644 --- a/oxi/interfaces/base.py +++ b/oxi/interfaces/base.py @@ -78,6 +78,11 @@ class BaseDevice(ABC): } if "vlans" in self._declared_sections: + if "vlans" not in self.raw: + raise ValueError( + f"{self.__class__.__name__}: template '{self.template}' declares optional group " + f"'vlans', but TTP did not return it." + ) vlans_data = self.vlans() or [] result["vlans"] = [Vlans(**item) for item in vlans_data] return result