Add error handling for missing required fields in file label dictionary in pr_description.py

This commit is contained in:
mrT23
2024-08-13 12:16:52 +03:00
parent 78b11c80c7
commit 8038eaf876

View File

@ -510,6 +510,12 @@ extra_file_yaml =
file_label_dict = {}
for file in self.data['pr_files']:
try:
required_fields = ['changes_summary', 'changes_title', 'filename', 'label']
if not all(field in file for field in required_fields):
# can happen for example if a YAML generation was interrupted in the middle (no more tokens)
get_logger().warning(f"Missing required fields in file label dict {self.pr_id}, skipping file",
artifact={"file": file})
continue
filename = file['filename'].replace("'", "`").replace('"', '`')
changes_summary = file['changes_summary']
changes_title = file['changes_title'].strip()