fix(jira): clear stale assignee on hand-off to blue team / dual validation
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled

The red_lead reviewer stayed assigned in Jira through blue_evaluating
(and the blue_lead reviewer through in_review) since push_test_event
never touched the assignee on those transitions — only red_executing
and the review gates did. Both are hand-offs with no single owner yet,
so the assignee is cleared instead of left stale.

Also fixes push_bt_work_started never assigning the blue_tech who
actually picks up the queued test — it only moved the status to
In Progress before.
This commit is contained in:
kitos
2026-07-10 16:49:16 +02:00
parent 0fc2427f71
commit 337faf824d
2 changed files with 48 additions and 1 deletions
+25
View File
@@ -859,6 +859,21 @@ def push_test_event(
link.jira_issue_key, jira_account_id, exc_a,
)
# Both are hand-off points to a different team with no single owner
# yet: blue_evaluating is queued for Blue Team (whoever reviewed the
# red side is done with it), and in_review is dual-validation by both
# leads at once. Leaving the previous assignee (red/blue reviewer)
# stuck on the ticket is misleading, so clear it.
if new_state in ("blue_evaluating", "in_review"):
try:
jira.assign_issue(link.jira_issue_key, account_id=None)
logger.info("Unassigned Jira ticket %s (state=%s)", link.jira_issue_key, new_state)
except Exception as exc_a:
logger.warning(
"Could not unassign %s for state %s: %s",
link.jira_issue_key, new_state, exc_a,
)
link.last_synced_at = datetime.utcnow()
db.flush()
logger.info(
@@ -1067,6 +1082,16 @@ def push_bt_work_started(db: Session, test, actor) -> None:
except Exception as exc_t:
logger.warning("Could not transition %s to In Progress: %s", link.jira_issue_key, exc_t)
jira.issue_add_comment(link.jira_issue_key, comment)
jira_account_id = getattr(actor, "jira_account_id", None)
if jira_account_id:
try:
jira.assign_issue(link.jira_issue_key, account_id=jira_account_id)
except Exception as exc_a:
logger.warning(
"Could not assign %s to %s: %s", link.jira_issue_key, jira_account_id, exc_a,
)
link.last_synced_at = datetime.utcnow()
db.flush()
logger.info("Posted blue-team-started event to Jira %s", link.jira_issue_key)
+23 -1
View File
@@ -149,6 +149,26 @@ def test_push_test_event_maps_every_state_to_jira_status(
mock_jira.set_issue_status.assert_called_once_with(link.jira_issue_key, expected_status)
@pytest.mark.parametrize("new_state", ["blue_evaluating", "in_review"])
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
@patch("app.services.jira_service.get_admin_jira_client")
def test_push_test_event_clears_assignee_on_handoff(mock_get_client, mock_configured, db, new_state):
"""Regression: the previous reviewer's assignment must not linger on the
ticket after a hand-off to a different team / dual-validation stage —
e.g. approving red_review left the red_lead reviewer stuck as assignee
all through blue_evaluating."""
mock_jira = MagicMock()
mock_get_client.return_value = mock_jira
test = _make_test()
link = _make_link(test.id)
db.add(link)
db.commit()
jira_service.push_test_event(db, test, MagicMock(username="alice", jira_account_id=None), new_state)
mock_jira.assign_issue.assert_called_once_with(link.jira_issue_key, account_id=None)
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
@patch("app.services.jira_service.get_admin_jira_client")
def test_push_bt_work_started_sets_in_progress(mock_get_client, mock_configured, db):
@@ -163,9 +183,11 @@ def test_push_bt_work_started_sets_in_progress(mock_get_client, mock_configured,
db.add(link)
db.commit()
jira_service.push_bt_work_started(db, test, MagicMock(username="bob"))
actor = MagicMock(username="bob", jira_account_id="bob-account-id")
jira_service.push_bt_work_started(db, test, actor)
mock_jira.set_issue_status.assert_called_once_with(link.jira_issue_key, "In Progress")
mock_jira.assign_issue.assert_called_once_with(link.jira_issue_key, account_id="bob-account-id")
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)