Skip to content

Commit 84a45cf

Browse files
authored
Unset priority using real null value (#1212)
Unset priority using real null value
1 parent 6153d00 commit 84a45cf

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

config/config.prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@
389389
status_map: *basic-status-map
390390
resolution_map: *basic-resolution-map
391391
priority_map:
392-
"": (none)
392+
"--": (None)
393393
P1: P1
394394
P2: P2
395395
P3: P3

jbi/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class ActionParams(BaseModel, frozen=True):
9797
labels_brackets: Literal["yes", "no", "both"] = "no"
9898
status_map: dict[str, str] = {}
9999
priority_map: dict[str, str] = {
100-
"": "(none)",
100+
"": "(None)",
101+
"--": "(None)",
101102
"P1": "P1",
102103
"P2": "P2",
103104
"P3": "P3",
@@ -107,6 +108,7 @@ class ActionParams(BaseModel, frozen=True):
107108
resolution_map: dict[str, str] = {}
108109
severity_map: dict[str, str] = {
109110
"": "N/A",
111+
"--": "N/A",
110112
"S1": "S1",
111113
"S2": "S2",
112114
"S3": "S3",

jbi/steps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ def _maybe_update_issue_mapped_field(
280280
)
281281
return (StepStatus.INCOMPLETE, context)
282282

283+
# Special handling for clearing fields in Jira.
284+
if target_value == "(None)":
285+
target_value = None
286+
wrap_value = None
287+
283288
resp = jira_service.update_issue_field(
284289
context,
285290
target_field,

tests/unit/test_steps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,10 @@ def test_update_issue_remove_priority(
825825
action_context = action_context_factory(
826826
operation=Operation.UPDATE,
827827
jira__issue="JBI-234",
828-
bug__priority=None,
828+
bug__priority="--",
829829
current_step="maybe_update_issue_priority",
830830
event__changes=[
831-
webhook_event_change_factory(field="priority", removed="P1", added="--")
831+
webhook_event_change_factory(field="priority", removed="P1", added="")
832832
],
833833
)
834834
params = action_params_factory(
@@ -841,7 +841,7 @@ def test_update_issue_remove_priority(
841841

842842
assert result == steps.StepStatus.SUCCESS
843843
mocked_jira.update_issue_field.assert_called_with(
844-
key="JBI-234", fields={"priority": {"name": "(none)"}}
844+
key="JBI-234", fields={"priority": None}
845845
)
846846

847847

0 commit comments

Comments
 (0)