From bd0586d296328a24eef6abd41adea3ac064094fa Mon Sep 17 00:00:00 2001 From: kitos Date: Wed, 27 May 2026 11:10:03 +0200 Subject: [PATCH] fix(jira): campaign=Task, campaign tests=Sub-task, standalone tests=Task Root cause: Jira rejects Task-under-Task nesting ("Please select valid parent issue"). Campaign tickets and test tickets were both created as Task, so nesting test under campaign failed for all 62 APT32 tests. Fix: - JIRA_ISSUE_TYPE_CAMPAIGN: "Epic" -> "Task" (was unused, now used) - JIRA_ISSUE_TYPE_SUBTASK: "Sub-task" (new config key) - auto_create_campaign_issue: uses JIRA_ISSUE_TYPE_CAMPAIGN (Task) - auto_create_test_issue: uses Sub-task when parent_ticket_override is set (campaign context), Task otherwise (standalone) Hierarchy: OFS-9107 -> Campaign (Task) -> Test (Sub-task) Co-Authored-By: Claude Sonnet 4.6 --- backend/app/config.py | 3 ++- backend/app/services/jira_service.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/app/config.py b/backend/app/config.py index 8dfb3b6..b4f82cd 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -52,7 +52,8 @@ class Settings(BaseSettings): JIRA_IS_CLOUD: bool = True JIRA_DEFAULT_PROJECT: str = "" JIRA_ISSUE_TYPE_TEST: str = "Task" - JIRA_ISSUE_TYPE_CAMPAIGN: str = "Epic" + JIRA_ISSUE_TYPE_CAMPAIGN: str = "Task" + JIRA_ISSUE_TYPE_SUBTASK: str = "Sub-task" # ── Tempo Integration ───────────────────────────────────────────── TEMPO_ENABLED: bool = False diff --git a/backend/app/services/jira_service.py b/backend/app/services/jira_service.py index 48a0f4b..0f67d1b 100644 --- a/backend/app/services/jira_service.py +++ b/backend/app/services/jira_service.py @@ -393,7 +393,7 @@ def auto_create_campaign_issue( "project": {"key": project_key}, "summary": f"[Aegis Campaign] {campaign.name}", "description": _build_campaign_description(campaign), - "issuetype": {"name": settings.JIRA_ISSUE_TYPE_TEST}, + "issuetype": {"name": settings.JIRA_ISSUE_TYPE_CAMPAIGN}, "labels": ["aegis", "campaign"], } @@ -467,11 +467,18 @@ def auto_create_test_issue( try: jira = get_user_jira_client(actor, db) + # Tests nested under a campaign are Sub-tasks; standalone tests are Tasks + issue_type = ( + settings.JIRA_ISSUE_TYPE_SUBTASK + if parent_ticket_override + else settings.JIRA_ISSUE_TYPE_TEST + ) + fields: dict = { "project": {"key": project_key}, "summary": f"[Aegis] {mitre_id} — {test.name}", "description": _build_test_description(test, technique), - "issuetype": {"name": settings.JIRA_ISSUE_TYPE_TEST}, + "issuetype": {"name": issue_type}, "labels": ["aegis", "security-test", mitre_id.replace(".", "-")], }