Skip to content

Commit 76f5b94

Browse files
authored
Autoclear needinfo top crash (#2405)
* Identified where in the code the flags need to be cleared * Added function to help find needinfo flag requested by BugBot * Added search to find `needinfo` flag created closest to the comment regarding increasing severity * Added `comments.creation_date` as an included field when retrieving comments * Removed date parsing, added exact creation time match check, added support for multiple flags and/or severity comments * Removed flag * Removed unnecessary return statements * Included `flags` and `comments` when retrieving bugs * Moved the needinfo flag ID collection logic to `handle_bug()` * Pass the needinfo flags as a list, even if it does not remove `topcrash` keyword * Changed the conditional for populating the `needinfo_ids` field * Simplified code * Cleaned up code * Replaced `needinfo_ids` with `needinfos_to_remove` * Replaced a `get()` instance with direct access * Added flags as a field in `get_bz_params()`
1 parent 609ce08 commit 76f5b94

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

bugbot/rules/crash_small_volume.py

+39
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ def handle_bug(self, bug, data):
122122
),
123123
"keywords_to_remove": keywords_to_remove,
124124
"signatures": signatures,
125+
"needinfos_to_remove": (
126+
self.get_needinfo_topcrash_ids(bug)
127+
if "topcrash" in keywords_to_remove
128+
else []
129+
),
125130
}
126131

127132
return bug
@@ -180,6 +185,13 @@ def set_autofix(self, bugs):
180185
)
181186
)
182187
autofix["keywords"] = {"remove": list(bug["keywords_to_remove"])}
188+
autofix["flags"] = [
189+
{
190+
"id": flag_id,
191+
"status": "X",
192+
}
193+
for flag_id in bug["needinfos_to_remove"]
194+
]
183195

184196
if not bug["ignore_severity"] and all(
185197
signature in low_volume_signatures for signature in bug["signatures"]
@@ -202,6 +214,31 @@ def set_autofix(self, bugs):
202214
}
203215
self.autofix_changes[bugid] = autofix
204216

217+
def get_needinfo_topcrash_ids(self, bug: dict) -> list[int]:
218+
"""Get the IDs of the needinfo flags requested by the bot regarding increasing the severity."""
219+
needinfo_flags = [
220+
flag
221+
for flag in bug["flags"]
222+
if flag["name"] == "needinfo" and flag["requestee"] == History.BOT
223+
]
224+
225+
needinfo_comment = (
226+
"could you consider increasing the severity of this top-crash bug?"
227+
)
228+
229+
severity_comment_times = [
230+
comment["creation_time"]
231+
for comment in bug["comments"]
232+
if comment["creator"] == History.BOT
233+
and needinfo_comment in comment["raw_text"]
234+
]
235+
236+
return [
237+
flag["id"]
238+
for flag in needinfo_flags
239+
if flag["creation_date"] in severity_comment_times
240+
]
241+
205242
@staticmethod
206243
def _has_severity_downgrade_comment(bug):
207244
for comment in reversed(bug["comments"]):
@@ -250,7 +287,9 @@ def get_bz_params(self, date):
250287
"cf_crash_signature",
251288
"comments.raw_text",
252289
"comments.creator",
290+
"comments.creation_time",
253291
"history",
292+
"flags",
254293
]
255294
params = {
256295
"include_fields": fields,

0 commit comments

Comments
 (0)