From 0cd6ee830470b78488950442beaf83f6a6f6805c Mon Sep 17 00:00:00 2001 From: naorpeled Date: Fri, 26 Jun 2026 23:02:04 +0300 Subject: [PATCH 1/3] fix(tickets): prevent /review and /describe crash on linked issues with sub-issues Sub-issue entries built in extract_tickets() omitted the 'labels' key that main-issue entries include. The reviewer/description prompts (and the token_handler pre-pass) render related_tickets under StrictUndefined, so accessing the missing ticket.labels raised UndefinedError, aborting the prompt render before any model call. Add an empty 'labels' key to sub-issue entries and make both templates defensive with 'is defined and', matching the existing ticket.requirements guard. Fixes #2471 --- pr_agent/settings/pr_description_prompts.toml | 2 +- pr_agent/settings/pr_reviewer_prompts.toml | 2 +- pr_agent/tools/ticket_pr_compliance_check.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pr_agent/settings/pr_description_prompts.toml b/pr_agent/settings/pr_description_prompts.toml index 2627401ea9..6111d302f2 100644 --- a/pr_agent/settings/pr_description_prompts.toml +++ b/pr_agent/settings/pr_description_prompts.toml @@ -99,7 +99,7 @@ Related Ticket Info: {% for ticket in related_tickets %} ===== Ticket Title: '{{ ticket.title }}' -{%- if ticket.labels %} +{%- if ticket.labels is defined and ticket.labels %} Ticket Labels: {{ ticket.labels }} {%- endif %} {%- if ticket.body %} diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index bbe6c6d04c..2ba65acfbb 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -217,7 +217,7 @@ Ticket URL: '{{ ticket.ticket_url }}' Ticket Title: '{{ ticket.title }}' -{%- if ticket.labels %} +{%- if ticket.labels is defined and ticket.labels %} Ticket Labels: {{ ticket.labels }} diff --git a/pr_agent/tools/ticket_pr_compliance_check.py b/pr_agent/tools/ticket_pr_compliance_check.py index b323986b12..17959c84ef 100644 --- a/pr_agent/tools/ticket_pr_compliance_check.py +++ b/pr_agent/tools/ticket_pr_compliance_check.py @@ -171,7 +171,8 @@ async def extract_tickets(git_provider): sub_issues_content.append({ 'ticket_url': sub_issue_url, 'title': sub_issue.title, - 'body': sub_body + 'body': sub_body, + 'labels': "" # keep key present so StrictUndefined template render doesn't crash }) except Exception as e: get_logger().warning(f"Failed to fetch sub-issue content for {sub_issue_url}: {e}") From 22ec72b772a7c9853cafdc0b321ac8541ecc6d62 Mon Sep 17 00:00:00 2001 From: naorpeled Date: Fri, 26 Jun 2026 23:38:56 +0300 Subject: [PATCH 2/3] fix(tickets): extract sub-issue labels instead of stubbing empty string Sub-issues are regular GitHub issues and can carry labels, so extract them the same way main-issue labels are extracted rather than discarding the data. Falls back to an empty string when there are none, keeping the key present for the StrictUndefined template render. --- pr_agent/tools/ticket_pr_compliance_check.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pr_agent/tools/ticket_pr_compliance_check.py b/pr_agent/tools/ticket_pr_compliance_check.py index 17959c84ef..d623d66cfa 100644 --- a/pr_agent/tools/ticket_pr_compliance_check.py +++ b/pr_agent/tools/ticket_pr_compliance_check.py @@ -168,11 +168,20 @@ async def extract_tickets(git_provider): if len(sub_body) > MAX_TICKET_CHARACTERS: sub_body = sub_body[:MAX_TICKET_CHARACTERS] + "..." + # Extract sub-issue labels (sub-issues are regular issues and can have labels) + sub_labels = [] + try: + for label in sub_issue.labels: + sub_labels.append(label.name if hasattr(label, 'name') else label) + except Exception as e: + get_logger().error(f"Error extracting labels error= {e}", + artifact={"traceback": traceback.format_exc()}) + sub_issues_content.append({ 'ticket_url': sub_issue_url, 'title': sub_issue.title, 'body': sub_body, - 'labels': "" # keep key present so StrictUndefined template render doesn't crash + 'labels': ", ".join(sub_labels) # keep key present so StrictUndefined render doesn't crash }) except Exception as e: get_logger().warning(f"Failed to fetch sub-issue content for {sub_issue_url}: {e}") From cda33fd5307da2808d755930d1304b514d6cc782 Mon Sep 17 00:00:00 2001 From: naorpeled Date: Fri, 26 Jun 2026 23:40:49 +0300 Subject: [PATCH 3/3] chore(tickets): trim redundant comments on sub-issue label extraction --- pr_agent/tools/ticket_pr_compliance_check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/tools/ticket_pr_compliance_check.py b/pr_agent/tools/ticket_pr_compliance_check.py index d623d66cfa..f2ae1dca78 100644 --- a/pr_agent/tools/ticket_pr_compliance_check.py +++ b/pr_agent/tools/ticket_pr_compliance_check.py @@ -168,7 +168,7 @@ async def extract_tickets(git_provider): if len(sub_body) > MAX_TICKET_CHARACTERS: sub_body = sub_body[:MAX_TICKET_CHARACTERS] + "..." - # Extract sub-issue labels (sub-issues are regular issues and can have labels) + # Extract sub-issue labels sub_labels = [] try: for label in sub_issue.labels: @@ -181,7 +181,7 @@ async def extract_tickets(git_provider): 'ticket_url': sub_issue_url, 'title': sub_issue.title, 'body': sub_body, - 'labels': ", ".join(sub_labels) # keep key present so StrictUndefined render doesn't crash + 'labels': ", ".join(sub_labels) }) except Exception as e: get_logger().warning(f"Failed to fetch sub-issue content for {sub_issue_url}: {e}")