From 8038eaf8763094d1afc55f60de4dd9a0cdf3da6f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 13 Aug 2024 12:16:52 +0300 Subject: [PATCH] Add error handling for missing required fields in file label dictionary in pr_description.py --- pr_agent/tools/pr_description.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index 7ba35fa4..2214085a 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -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()