Improve Jira issue parsing to support all project prefixes and handle…#315
Merged
kkaarreell merged 1 commit intomainfrom Feb 5, 2026
Merged
Improve Jira issue parsing to support all project prefixes and handle…#315kkaarreell merged 1 commit intomainfrom
kkaarreell merged 1 commit intomainfrom
Conversation
Reviewer's GuideExpands Jira issue extraction to support any uppercase project prefix and adds explicit error handling and display for Jira issues that are missing or access-restricted. Sequence diagram for Jira summarize command with enhanced issue parsing and error handlingsequenceDiagram
actor User
participant SummarizeCLI as SummarizeCLI
participant ExtractHelper as extract_jira_issues_from_comment
participant FetchBulk as fetch_jira_issues_bulk
participant JiraClient as jira_client
participant JiraServer as Jira
participant Formatter as format_jira_issue_details
User->>SummarizeCLI: run_summarize_command(comment)
SummarizeCLI->>ExtractHelper: extract_jira_issues_from_comment(comment)
ExtractHelper-->>SummarizeCLI: issue_keys [A_Z_prefix-NNNN]
SummarizeCLI->>FetchBulk: fetch_jira_issues_bulk(jira_client, issue_keys)
FetchBulk->>JiraClient: search_issues(jql_for_issue_keys)
JiraClient->>JiraServer: search_issues
JiraServer-->>JiraClient: list_of_found_issues
JiraClient-->>FetchBulk: issues
loop for_each_found_issue
FetchBulk->>FetchBulk: build_issue_details_dict
FetchBulk->>FetchBulk: add_issue_key_to_found_keys
end
loop for_each_valid_key
Note over FetchBulk: new behavior
FetchBulk->>FetchBulk: if key_not_in_found_keys
FetchBulk->>FetchBulk: result[key] = {error: issue_not_found_or_restricted}
end
FetchBulk-->>SummarizeCLI: jira_issues_data
SummarizeCLI->>Formatter: format_jira_issue_details(jira_issues_data)
alt entry_contains_error
Formatter->>Formatter: detect error in_issue_dict
Formatter-->>SummarizeCLI: [Issue: KEY, Error: message]
else normal_issue
Formatter->>Formatter: format components, affects_versions, fix_versions
Formatter-->>SummarizeCLI: formatted_issue_details
end
SummarizeCLI-->>User: printed_summary_with_errors_and_valid_issues
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
extract_jira_issues_from_comment, the regex has been generalized to[A-Z]+-\d{4,8}, which will now match any all‑caps prefix; if you want to avoid accidentally capturing non‑Jira tokens, consider constraining the project key (e.g. minimum length or known prefixes) or making it configurable. - The error sentinel
{'error': ...}is now relied upon in bothfetch_jira_issues_bulkandformat_jira_issue_details; consider defining a small typed wrapper or a dedicated field name/constant to avoid accidental key collisions and to make the contract between these functions clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `extract_jira_issues_from_comment`, the regex has been generalized to `[A-Z]+-\d{4,8}`, which will now match any all‑caps prefix; if you want to avoid accidentally capturing non‑Jira tokens, consider constraining the project key (e.g. minimum length or known prefixes) or making it configurable.
- The error sentinel `{'error': ...}` is now relied upon in both `fetch_jira_issues_bulk` and `format_jira_issue_details`; consider defining a small typed wrapper or a dedicated field name/constant to avoid accidental key collisions and to make the contract between these functions clearer.
## Individual Comments
### Comment 1
<location> `newa/cli/summarize_helpers.py:29` </location>
<code_context>
return []
- pattern = r'\b(RHEL-\d{4,8})\b'
+ pattern = r'\b([A-Z]+-\d{4,8})\b'
return re.findall(pattern, comment)
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The generalized Jira key pattern may be overly permissive for project key names.
This pattern will also match single-letter project keys and other unlikely variants. If your Jira keys follow the usual 2–10 uppercase letters, consider tightening it to something like:
```python
pattern = r'\b([A-Z]{2,10}-\d{1,8})\b'
```
to reduce false positives in arbitrary text.
```suggestion
pattern = r'\b([A-Z]{2,10}-\d{1,8})\b'
```
</issue_to_address>
### Comment 2
<location> `newa/cli/commands/summarize_cmd.py:30-34` </location>
<code_context>
+ Dictionary mapping issue key to issue details. For issues that don't exist
+ or are restricted, the value will be {'error': 'error message'}
"""
+ issue_not_found_error = "Issue either doesn't exist or the access to it is restricted"
+
if not issue_keys:
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Error handling is inconsistent between partial-not-found cases and full failure cases.
When `search_issues` succeeds, missing/restricted issues are marked with `issue_not_found_error`. But if `search_issues` (or any upstream call) raises, the `except` block returns an empty dict, so callers can’t distinguish a total failure from “no issues”. In the exception path, consider returning `{key: {"error": issue_not_found_error}}` for all requested (or at least `valid_keys`) to keep the error contract consistent and avoid ambiguous empty results.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
bde17ee to
a9a6abe
Compare
… missing issues Update the Jira issue extraction regex to match any project prefix (e.g., RHEL-1234, JIRA-5678) instead of only RHEL issues. Add error handling for issues that don't exist or are restricted, displaying a clear error message instead of omitting them from the output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
a9a6abe to
f3d3d15
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… missing issues
Update the Jira issue extraction regex to match any project prefix (e.g., RHEL-1234, JIRA-5678) instead of only RHEL issues. Add error handling for issues that don't exist or are restricted, displaying a clear error message instead of omitting them from the output.
🤖 Generated with Claude Code
Summary by Sourcery
Expand Jira issue extraction and surface errors for missing or inaccessible issues in summarize CLI output.
New Features:
Enhancements: