From 946c3e2297aefc0b2998009a8a49a96640dbc30d Mon Sep 17 00:00:00 2001 From: wishhyt <24300810017@m.fudan.edu.cn> Date: Wed, 18 Mar 2026 10:35:35 +0800 Subject: [PATCH] fix: prevent KeyError when removing type from PR description data When `enable_pr_type` is False, `self.data.pop('type')` raises KeyError if the AI response YAML does not contain a 'type' field. Use `pop('type', None)` for safe removal, consistent with the adjacent `labels` removal which already guards with an `in` check. Made-with: Cursor --- pr_agent/tools/pr_description.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index db1492c6bb..32f8837200 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -561,7 +561,7 @@ def _prepare_pr_answer(self) -> Tuple[str, str, str, List[dict]]: if 'labels' in self.data and self.git_provider.is_supported("get_labels"): self.data.pop('labels') if not get_settings().pr_description.enable_pr_type: - self.data.pop('type') + self.data.pop('type', None) # Remove the 'PR Title' key from the dictionary ai_title = self.data.pop('title', self.vars["title"])