Skip to content

Commit 9b8701a

Browse files
authored
fix: remove processing raw yaml files in exception cause generation (#1233)
This PR related to PR #1090 which requests removal of processing raw yaml files in exception cause generation to prevent generation of wrong codes #1145
1 parent 15e139b commit 9b8701a

File tree

1 file changed

+4
-52
lines changed

1 file changed

+4
-52
lines changed

backends/generators/generator.py

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -562,58 +562,10 @@ def load_exception_codes(
562562
logging.error(
563563
f"Error loading resolved codes file {resolved_codes_file}: {e}"
564564
)
565-
# Fall back to processing YAML files
566-
567-
for dirpath, _, filenames in os.walk(ext_dir):
568-
for fname in filenames:
569-
if not fname.endswith(".yaml"):
570-
continue
571-
572-
found_files += 1
573-
path = os.path.join(dirpath, fname)
574-
575-
try:
576-
with open(path, encoding="utf-8") as f:
577-
data = yaml.safe_load(f)
578-
579-
if not isinstance(data, dict) or data.get("kind") != "extension":
580-
continue
581-
582-
found_extensions += 1
583-
ext_name = data.get("name", "unnamed")
584-
585-
# Skip extension filtering if include_all is True
586-
if not include_all:
587-
# Filter by extension requirements
588-
definedBy = data.get("definedBy")
589-
if definedBy:
590-
meets_req = parse_extension_requirements(definedBy)
591-
if not meets_req(enabled_extensions):
592-
continue
593-
594-
# Check if excluded
595-
excludedBy = data.get("excludedBy")
596-
if excludedBy:
597-
exclusion_check = parse_extension_requirements(excludedBy)
598-
if exclusion_check(enabled_extensions):
599-
continue
600-
601-
# Get exception codes
602-
for code in data.get("exception_codes", []):
603-
num = code.get("num")
604-
name = code.get("name")
605-
606-
if num is not None and name is not None:
607-
sanitized_name = (
608-
name.lower()
609-
.replace(" ", "_")
610-
.replace("/", "_")
611-
.replace("-", "_")
612-
)
613-
exception_codes.append((num, sanitized_name))
614-
615-
except Exception as e:
616-
logging.error(f"Error processing file {path}: {e}")
565+
# Logging an error and skipping the exception cause generation if no resolved codes file found
566+
else:
567+
logging.error(f"Error loading resolved codes file {resolved_codes_file}: {e}")
568+
return
617569

618570
if found_extensions > 0:
619571
logging.info(

0 commit comments

Comments
 (0)