Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions keep/providers/jiraonprem_provider/jiraonprem_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def __update_issue(
issue_id: str,
summary: str = "",
description: str = "",
priority: str = "Medium",
priority: str = None,
labels: List[str] = None,
components: List[str] = None,
custom_fields: dict = None,
Expand Down Expand Up @@ -521,7 +521,7 @@ def _notify(
labels: List[str] = None,
components: List[str] = None,
custom_fields: dict = None,
priority: str = "Medium",
priority: str = None,
**kwargs: dict,
):
"""
Expand Down Expand Up @@ -574,7 +574,7 @@ def _notify(
labels=labels,
components=components,
custom_fields=custom_fields,
priority=priority,
priority=priority or "Medium",
**kwargs,
)
result["ticket_url"] = f"{self.jira_host}/browse/{result['issue']['key']}"
Expand Down
45 changes: 45 additions & 0 deletions tests/test_jira_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,48 @@ def test_notify_with_string_kwargs_handling(self, jira_provider):

# If we get here without the "string indices must be integers" error, the fix worked
assert result is not None

@patch("requests.put")
@patch("requests.get")
def test_jiraonprem_update_issue_preserves_priority_when_unspecified(
self, mock_get, mock_put, jiraonprem_provider
):
"""Test that updating an issue without specifying priority does not inject or reset priority (#6751)"""
mock_get.return_value.status_code = 200
mock_get.return_value.json.return_value = {"key": "TEST-123"}
mock_put.return_value.status_code = 204

jiraonprem_provider._notify(
issue_id="TEST-123",
summary="New Summary",
description="New Description",
)

mock_put.assert_called_once()
request_body = mock_put.call_args[1]["json"]
assert "update" in request_body
assert "summary" in request_body["update"]
assert "description" in request_body["update"]
assert "priority" not in request_body["update"]

@patch("requests.put")
@patch("requests.get")
def test_jiraonprem_update_issue_forwards_explicit_priority(
self, mock_get, mock_put, jiraonprem_provider
):
"""Test that updating an issue with explicit priority updates the priority field (#6751)"""
mock_get.return_value.status_code = 200
mock_get.return_value.json.return_value = {"key": "TEST-123"}
mock_put.return_value.status_code = 204

jiraonprem_provider._notify(
issue_id="TEST-123",
summary="New Summary",
priority="Highest",
)

mock_put.assert_called_once()
request_body = mock_put.call_args[1]["json"]
assert "update" in request_body
assert "priority" in request_body["update"]
assert request_body["update"]["priority"] == [{"set": {"name": "Highest"}}]
Loading