From 27184627f8fba6941bb271bf41b12dd78a84160f Mon Sep 17 00:00:00 2001 From: kitos Date: Wed, 27 May 2026 16:19:01 +0200 Subject: [PATCH] fix(jira): standalone tests as Sub-task under OFS-20798 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OFS-20798 is a Task (child of OFS-20795 Epic), so tests nested under it must be Sub-tasks, not Tasks — Task cannot parent Task. Logic: - parent_ticket_override (campaign) → Sub-task (unchanged) - standalone_parent configured and differs from general parent → Sub-task - only general parent (Epic) → Task This fixes 'Please select valid parent issue' for standalone tests. Co-Authored-By: Claude Sonnet 4.6 --- backend/app/services/jira_service.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/backend/app/services/jira_service.py b/backend/app/services/jira_service.py index 7e0ec16..4633d0a 100644 --- a/backend/app/services/jira_service.py +++ b/backend/app/services/jira_service.py @@ -478,10 +478,22 @@ 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 + # Resolve parent and issue type together: + # - campaign parent override → Sub-task (Task cannot parent Task) + # - explicit standalone parent configured → Sub-task (same reason; + # the standalone parent is a Task, e.g. OFS-20798) + # - only the general parent ticket (Epic) → Task + standalone_parent = get_jira_parent_ticket_standalone(db) + general_parent = get_jira_parent_ticket(db) + parent = parent_ticket_override or standalone_parent + + has_explicit_parent = bool( + parent_ticket_override + or (standalone_parent and standalone_parent != general_parent) + ) issue_type = ( settings.JIRA_ISSUE_TYPE_SUBTASK - if parent_ticket_override + if has_explicit_parent else settings.JIRA_ISSUE_TYPE_TEST ) @@ -493,10 +505,6 @@ def auto_create_test_issue( "labels": ["aegis", "security-test", mitre_id.replace(".", "-")], } - # Use campaign ticket as parent when provided; otherwise use the - # standalone-tests parent (e.g. OFS-20798), falling back to the - # general parent ticket if the standalone one is not configured. - parent = parent_ticket_override or get_jira_parent_ticket_standalone(db) if parent: fields["parent"] = {"key": parent}