From aa180b91ac74a02401787ad4212654a7e4a64979 Mon Sep 17 00:00:00 2001 From: Ondrej Tuma Date: Wed, 14 Oct 2026 13:43:39 +0200 Subject: [PATCH] Skip UUID derivation check for packages without GTIN The validator no longer crashes with KeyError when a material package has a uuid but no gtin. Such packages are skipped, since the UUID can't be derived (and may come from the manufacturer). --- scripts/validate_json_schema.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/validate_json_schema.py b/scripts/validate_json_schema.py index 7dfe9c45c..2d1492bd7 100755 --- a/scripts/validate_json_schema.py +++ b/scripts/validate_json_schema.py @@ -355,9 +355,15 @@ def validate_uuids(self) -> None: # FK validation will catch missing brand continue + # UUID is derived from GTIN; without GTIN (not required by the schema) + # the UUID can't be verified - it may be provided by the manufacturer. + gtin = package_data.get('gtin') + if gtin is None or 'uuid' not in package_data: + continue + try: brand_uuid = uuid.UUID(brand_data['uuid']) - expected_uuid = generate_material_package_uuid(brand_uuid, package_data['gtin']) + expected_uuid = generate_material_package_uuid(brand_uuid, gtin) is_valid = expected_uuid == uuid.UUID(package_data['uuid']) if not is_valid: self.errors.append(ValidationError(