fix(jira): standalone tests as Sub-task under OFS-20798
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled

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 <noreply@anthropic.com>
This commit is contained in:
kitos
2026-05-27 16:19:01 +02:00
parent 323964ed9d
commit 27184627f8

View File

@@ -478,10 +478,22 @@ def auto_create_test_issue(
try: try:
jira = get_user_jira_client(actor, db) 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 = ( issue_type = (
settings.JIRA_ISSUE_TYPE_SUBTASK settings.JIRA_ISSUE_TYPE_SUBTASK
if parent_ticket_override if has_explicit_parent
else settings.JIRA_ISSUE_TYPE_TEST else settings.JIRA_ISSUE_TYPE_TEST
) )
@@ -493,10 +505,6 @@ def auto_create_test_issue(
"labels": ["aegis", "security-test", mitre_id.replace(".", "-")], "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: if parent:
fields["parent"] = {"key": parent} fields["parent"] = {"key": parent}