From b7d7569e026621eb333c2799b696ea709e1f04e9 Mon Sep 17 00:00:00 2001 From: Khushal Malhotra Date: Fri, 13 Mar 2026 19:39:38 +0530 Subject: [PATCH 1/2] Fix crash on empty YAML files in convert.py - Add null checks after yaml.safe_load() calls - Prevent AttributeError when data is None - Handle both empty files and explicit null content - Protect build system from crashing on empty YAML files Fixes issue where empty YAML files in source/ directory would cause: AttributeError: 'NoneType' object has no attribute 'keys' --- scripts/convert.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/convert.py b/scripts/convert.py index 3f60754fc..fbc44bf6d 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -636,6 +636,9 @@ def get_mapping_data_for_edition( with open(mappingfile, "r", encoding="utf-8") as f: try: data = yaml.safe_load(f) + # Handle empty/null YAML files + if data is None: + data = {} except yaml.YAMLError as e: logging.info(f"Error loading yaml file: {mappingfile}. Error = {e}") data = {} @@ -737,6 +740,9 @@ def get_language_data( with open(language_file, "r", encoding="utf-8") as f: try: data = yaml.safe_load(f) + # Handle empty/null YAML files + if data is None: + data = {} except yaml.YAMLError as e: logging.error(f"Error loading yaml file: {language_file}. Error = {e}") data = {} From 77a4770b47707525b27081277d1bd79532c78c2a Mon Sep 17 00:00:00 2001 From: Khushal Malhotra Date: Fri, 13 Mar 2026 19:47:27 +0530 Subject: [PATCH 2/2] Improve YAML validation to handle all data types - Change from checking 'data is None' to 'not isinstance(data, dict)' - Handles scalars, lists, and other non-dict YAML content types - Prevents AttributeError on data.keys() and data['meta'] operations - More robust than previous None-only check Fixes edge cases where YAML files contain non-dictionary content that would still cause crashes despite previous None check. --- scripts/convert.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/convert.py b/scripts/convert.py index fbc44bf6d..fef9a9bae 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -636,8 +636,8 @@ def get_mapping_data_for_edition( with open(mappingfile, "r", encoding="utf-8") as f: try: data = yaml.safe_load(f) - # Handle empty/null YAML files - if data is None: + # Handle empty/null YAML files and validate it's a dict + if not isinstance(data, dict): data = {} except yaml.YAMLError as e: logging.info(f"Error loading yaml file: {mappingfile}. Error = {e}") @@ -740,8 +740,8 @@ def get_language_data( with open(language_file, "r", encoding="utf-8") as f: try: data = yaml.safe_load(f) - # Handle empty/null YAML files - if data is None: + # Handle empty/null YAML files and validate it's a dict + if not isinstance(data, dict): data = {} except yaml.YAMLError as e: logging.error(f"Error loading yaml file: {language_file}. Error = {e}")