Skip to content

Commit 464432a

Browse files
author
Bryan Sieber
committed
When getting bug data, comment data is lost--overwriting payload's bug loses comment info
1 parent 4884364 commit 464432a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ dmypy.json
132132
.isort.cfg
133133

134134
# Don't check in your own Env
135-
infra/config/local_dev.env
135+
*local_dev.env

src/jbi/router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def execute_action(request: BugzillaWebhookRequest, action_map, settings):
4646
if is_private_bug:
4747
raise IgnoreInvalidRequestError("private bugs are not valid")
4848

49-
request.bug = getbug_as_bugzilla_object(request=request)
50-
current_action = extract_current_action(request.bug, action_map) # type: ignore
49+
bug_obj = getbug_as_bugzilla_object(request=request)
50+
current_action = extract_current_action(bug_obj, action_map) # type: ignore
5151
if not current_action:
5252
raise IgnoreInvalidRequestError(
5353
"whiteboard tag not found in configured actions"

src/jbi/whiteboard_actions/default.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def bug_create_or_update(
6060
self, payload: BugzillaWebhookRequest
6161
): # pylint: disable=too-many-locals
6262
"""Create and link jira issue with bug, or update; rollback if multiple events fire"""
63-
linked_issue_key = payload.bug.extract_from_see_also() # type: ignore
63+
linked_issue_key = getbug_as_bugzilla_object(payload).extract_from_see_also() # type: ignore
6464
if linked_issue_key:
6565
# update
6666
fields, comments = payload.map_as_tuple_of_field_dict_and_comments()
@@ -84,7 +84,14 @@ def bug_create_or_update(
8484

8585
def create_and_link_issue(self, payload):
8686
"""create jira issue and establish link between bug and issue; rollback/delete if required"""
87-
fields = {**payload.bug.map_as_jira_issue(), "project": {"key": self.jira_project_key}} # type: ignore
87+
comment_list = self.bugzilla_client.get_comments(idlist=[payload.bug.id])
88+
fields = {
89+
**payload.bug.map_as_jira_issue(), # type: ignore
90+
"description": comment_list["bugs"][str(payload.bug.id)]["comments"][0][
91+
"text"
92+
],
93+
"project": {"key": self.jira_project_key},
94+
}
8895

8996
jira_response_create = self.jira_client.create_issue(fields=fields)
9097

0 commit comments

Comments
 (0)