feat: add Asana ticket detection to ticket compliance check#2430
feat: add Asana ticket detection to ticket compliance check#2430Oxygen56 wants to merge 17 commits into
Conversation
Review Summary by QodoAdd Asana ticket detection and fix indentation normalization
WalkthroughsDescription• Add Asana ticket detection to PR compliance check - Supports full URLs and ASANA-123456789 shorthand format - Asana tickets included in related tickets list • Fix indentation character preservation in /improve suggestions - Handle negative delta_spaces with dedent operation - Normalize tabs/spaces to match original file's indentation Diagramflowchart LR
A["PR Description & Branch"] -->|find_asana_tickets| B["Asana URLs Detected"]
B -->|extract_tickets| C["Merged Ticket List"]
C -->|Asana URLs| D["Placeholder Content"]
E["Code Suggestions"] -->|dedent_code| F["Normalize Indentation"]
F -->|Detect char| G["Tab or Space"]
G -->|Apply| H["Corrected Code"]
File Changes1. pr_agent/tools/pr_code_suggestions.py
|
Code Review by Qodo
Context used✅ Tickets:
🎫 Add Support for Asana Ticket Provider 1. extract_tickets() can return None
|
|
Hey @Oxygen56, Can you please add tests to validate the new functionality? 🙏 |
|
Code review by qodo was updated up to the latest commit a2bf77a |
|
Code review by qodo was updated up to the latest commit a0c62b4 |
|
感谢所有 review 意见,我已在最新提交中处理了以下问题: Bug 修复:
规范/安全修复:
测试补充:
|
The dedent_code method only adjusted indentation when delta_spaces > 0 and never normalized the indentation character. This caused /improve to replace tabs with spaces in Go, Makefile, and other tab-indented codebases. Changes: - Handle delta_spaces < 0 case with dedent (not just > 0) - Normalize all suggestion lines to use the original file's indentation character (tab or space), auto-detected from the existing code Fixes The-PR-Agent#1858 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds support for detecting Asana task references in PR descriptions and branch names. Supports both full URLs and ASANA-123456789 shorthand format. - find_asana_tickets() extracts Asana task URLs from text - Asana tickets are included in the compliance check's related tickets - Graceful handling: Asana URLs are shown with a placeholder body since they cannot be fetched via the GitHub API Fixes The-PR-Agent#2002 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Use ticket_url instead of url (templates access ticket.ticket_url) - Add labels field (templates access ticket.labels under StrictUndefined) - Add ticket_id field for consistency with GitHub ticket entries
- Replace textwrap.dedent() with exact -delta_spaces removal to avoid stripping too much indentation when lines have varying levels - Preserve remainder spaces when converting spaces to tabs (e.g. 6 spaces → 1 tab + 2 spaces instead of silently dropping 2)
…check - Covers full Asana URLs, shorthand ASANA- prefix, case-insensitivity - Tests deduplication, sorting, empty input, and mixed PR description content - Validates GitHub URLs are not misidentified as Asana tickets
- Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN, _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6). - Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper case-insensitive matching. - Replace substring match ('app.asana.com' in ticket) with prefix check (ticket.startswith()) to fix CodeQL URL sanitization warning (comment The-PR-Agent#4). - Reserve at least one slot for Asana tickets during truncation when there are 3+ GitHub/branch tickets (comment The-PR-Agent#8). - Dedent only actual leading whitespace instead of blindly slicing dline[remove_count:] to avoid deleting real code on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9). - Remove unused 'import pytest' from test file (comments The-PR-Agent#10/The-PR-Agent#20). - Add test_shorthand_mixed_case_asana and test_shorthand_respects_word_boundary test cases.
2921c2b to
3ce5450
Compare
|
Code review by qodo was updated up to the latest commit 3ce5450 |
|
Hey @naorpeled, thanks for the review! Tests have been added — there are now 12 test cases in
The test file was added in commit |
|
There are docs ( |
…ode_suggestions.py, update docs with Asana support
|
Updated |
|
Tests for the Asana ticket detection are already included in this PR — see |
|
Code review by qodo was updated up to the latest commit 0573be2 |
Per maintainer feedback (naorpeled), remove the invented ASANA- prefix shorthand since Asana has no native shorthand format like Jira's PROJ-123. Only full Asana URLs are now supported. - Remove _ASANA_TASK_SHORT_PATTERN regex and matching loop - Update find_asana_tickets() docstring - Update docs to remove shorthand format references - Update tests to use full URLs only, drop shorthand-specific cases
|
Code review by qodo was updated up to the latest commit 4caee4c |
|
Hey @Oxygen56, Thanks! |
Add extract_tickets coverage for Asana references, including the capped-ticket path that reserves a slot for an Asana URL.
|
Thanks for the nudge. I addressed the remaining Qodo items in the latest push:
Validation run locally:
|
| # Skip Asana URLs — these are external references, | ||
| # included for visibility but cannot be fetched via GitHub API. | ||
| if ticket.startswith("https://app.asana.com/"): | ||
| tickets_content.append({ | ||
| "ticket_id": ticket, | ||
| "ticket_url": ticket, | ||
| "title": f"Asana Task: {ticket}", | ||
| "body": ("Asana task referenced in PR description. " | ||
| "Fetch task details from Asana for full context."), | ||
| "labels": "", | ||
| }) | ||
| continue |
There was a problem hiding this comment.
1. extract_tickets skips asana fetching 📎 Requirement gap ≡ Correctness
The new Asana handling explicitly avoids fetching any Asana task data and only adds a placeholder entry, so Asana cannot be used as a real ticket provider end-to-end. This violates the requirement to integrate an Asana Ticket Provider into the existing ticket fetching/compliance infrastructure.
Agent Prompt
## Issue description
The current Asana support only detects Asana URLs and explicitly skips fetching task details, meaning Asana is not implemented as an integrated ticket provider.
## Issue Context
PR Compliance requires Asana to be supported as a ticket provider in the same infrastructure used for other providers, so compliance checks can consume fetched Asana ticket/task data end-to-end.
## Fix Focus Areas
- pr_agent/tools/ticket_pr_compliance_check.py[150-183]
- docs/docs/core-abilities/fetching_ticket_context.md[97-112]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 65460ce |
|
Thanks, I pushed bc043c7 to address the actionable new Qodo items:
Validation:
On the broader Asana fetching note: this PR currently keeps Asana references as detection/reference-only, matching the docs added here. Implementing full Asana API fetching would require new provider config/auth handling, so I am keeping that out of scope unless you want this PR expanded in that direction. |
| # Also detect Asana ticket references in the PR description | ||
| asana_tickets = find_asana_tickets(user_description) | ||
| for link in asana_tickets: | ||
| if link not in seen: | ||
| seen.add(link) | ||
| merged.append(link) | ||
| asana_links = [t for t in merged if t.startswith("https://app.asana.com/")] | ||
| github_like = [t for t in merged if not t.startswith("https://app.asana.com/")] |
There was a problem hiding this comment.
1. Asana detection github-only 🐞 Bug ≡ Correctness
find_asana_tickets() is only invoked inside the isinstance(git_provider, GithubProvider) branch of extract_tickets(), so non-GitHub providers will never include Asana references in related_tickets. This makes Asana ticket compliance visibility silently unavailable for other configured providers.
Agent Prompt
## Issue description
Asana ticket detection is currently executed only when `extract_tickets()` is running in the `GithubProvider` code path. For other supported git providers, `extract_tickets()` never runs the Asana scan, so Asana references in PR descriptions are not included in `related_tickets`.
## Issue Context
- The repo supports multiple git providers.
- Docs state Asana detection “works out of the box”, but the current implementation only activates for GitHub.
## Fix Focus Areas
- pr_agent/tools/ticket_pr_compliance_check.py[134-188]
### Implementation direction
- Move Asana reference extraction (`find_asana_tickets(...)`) to a provider-agnostic location in `extract_tickets()`.
- Use the provider base API (`git_provider.get_user_description()` exists on `GitProvider`) to obtain the text.
- For providers that are not GitHub/Azure, still return Asana placeholder ticket entries when Asana URLs are present (instead of returning `None` / no tickets).
- Keep GitHub issue fetching behavior unchanged; just merge in the Asana placeholder entries regardless of provider type.
- Add/adjust a unit test to cover a non-GitHub provider scenario (can be a minimal stub implementing `get_user_description()` and `get_pr_branch()`) to ensure Asana references are returned.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit bc043c7 |
|
Code review by qodo was updated up to the latest commit a096303 |
|
Pushed cf17141 for the latest Qodo pass:
Validation:
The remaining full Asana API fetching/provider-auth item is still a scope question rather than a small follow-up fix. |
|
Code review by qodo was updated up to the latest commit cf17141 |
|
Pushed 1c1a693 for the latest Qodo pass:
Validation:
A couple of remaining Qodo entries look stale or scope-level: non-GitHub Asana detection is already provider-agnostic and covered by |
| _append_asana_ticket_content( | ||
| tickets_content, | ||
| asana_tickets_to_include, | ||
| max_tickets, | ||
| ) | ||
| if tickets_content: | ||
| return tickets_content | ||
|
|
||
| except Exception as e: |
There was a problem hiding this comment.
1. extract_tickets() can return none 📘 Rule violation ☼ Reliability
extract_tickets() only returns when tickets_content is truthy, so callers can receive None when no tickets are found or when an exception occurs. This violates the requirement to handle edge cases gracefully and can cause downstream errors when code expects a list.
Agent Prompt
## Issue description
`extract_tickets()` may implicitly return `None` (no explicit return) when no tickets are found or when an exception is raised, because it only returns inside `if tickets_content:`.
## Issue Context
Callers of `extract_tickets()` generally expect a list (possibly empty). Returning `None` can break iteration/serialization and makes behavior inconsistent across providers and edge cases.
## Fix Focus Areas
- pr_agent/tools/ticket_pr_compliance_check.py[298-310]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 1c1a693 |
|
Follow-up pushed as c928e6c for the same
Validation remains green:
|
|
Code review by qodo was updated up to the latest commit c928e6c |
|
Pushed 557b28c for the new Qodo
Validation:
|
|
Code review by qodo was updated up to the latest commit 557b28c |
What
Fixes #2002 — Adds Asana task references detection to the PR ticket compliance check.
Problem
The ticket compliance check only detected GitHub issues and JIRA tickets. Teams using Asana had no automated ticket validation.
Solution
Adds
find_asana_tickets()that detects:https://app.asana.com/0/{project_id}/{task_id}ASANA-123456789012Asana references are included in the compliance check's related tickets alongside GitHub and JIRA references.