From 106449ef9b71a517007fe4ee253089b49a7e423a Mon Sep 17 00:00:00 2001 From: Aman Sachan Date: Mon, 1 Jun 2026 00:34:49 +0000 Subject: [PATCH] fix: guard against KeyError in get_priority_change_date by using .get() The change history entries may not always contain 'field_name' or 'added' keys, causing a KeyError when iterating through bug history. Using .get() with None default prevents the crash while preserving the original logic: only entries with field_name=='priority' and matching added value are used. Fixes mozilla/bugbot#2607 --- bugbot/rules/assignee_no_login.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bugbot/rules/assignee_no_login.py b/bugbot/rules/assignee_no_login.py index 456c49488..26aef6097 100644 --- a/bugbot/rules/assignee_no_login.py +++ b/bugbot/rules/assignee_no_login.py @@ -137,8 +137,8 @@ def get_priority_change_date(self, bug): for change in reversed(bug["history"]): if ( - change["field_name"] == "priority" - and change["added"] == current_priority + change.get("field_name") == "priority" + and change.get("added") == current_priority ): return datetime.strptime(change["when"], "%Y-%m-%dT%H:%M:%SZ") return None