Skip to content

Commit c81cb70

Browse files
Merge pull request #35 from mozilla/minor-fixes
Minor fixes based on initial testing
2 parents 289893a + 464432a commit c81cb70

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ dmypy.json
130130

131131
# iSort - Pre-Commit
132132
.isort.cfg
133+
134+
# Don't check in your own Env
135+
*local_dev.env

src/app/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Settings(BaseSettings):
1818

1919
# Jira
2020
jira_base_url: str = "https://mozit-test.atlassian.net/"
21-
jira_issue_url: str = f"{jira_base_url}/browse/%s"
21+
jira_issue_url: str = f"{jira_base_url}browse/%s"
2222
jira_username: str
2323
jira_password: str
2424

src/jbi/router.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ 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"
5454
)
5555

56+
jbi_logger.info("\nrequest: %s, \naction: %s", request.json(), current_action)
5657
action_module: ModuleType = importlib.import_module(current_action["action"])
5758
callable_action = action_module.init( # type: ignore
5859
**current_action["parameters"]

src/jbi/whiteboard_actions/default.py

Lines changed: 11 additions & 4 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(), "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

@@ -114,11 +121,11 @@ def create_and_link_issue(self, payload):
114121
)
115122
return {"status": "duplicate", "jira_response": jira_response_delete}
116123
# else:
117-
jira_url = self.settings.jira_issue_url.format(jira_key_in_response)
124+
jira_url = self.settings.jira_issue_url % jira_key_in_response
118125
update = self.bugzilla_client.build_update(see_also_add=jira_url)
119126
bugzilla_response = self.bugzilla_client.update_bugs([bug_obj.id], update)
120127

121-
bugzilla_url = self.settings.bugzilla_bug_url.format(bug_obj.id)
128+
bugzilla_url = self.settings.bugzilla_bug_url % bug_obj.id
122129
jira_response = self.jira_client.create_or_update_issue_remote_links(
123130
issue_key=jira_key_in_response,
124131
link_url=bugzilla_url,

0 commit comments

Comments
 (0)