Skip to content

Improve Jira issue parsing to support all project prefixes and handle…#315

Merged
kkaarreell merged 1 commit intomainfrom
ks_jira_parsin
Feb 5, 2026
Merged

Improve Jira issue parsing to support all project prefixes and handle…#315
kkaarreell merged 1 commit intomainfrom
ks_jira_parsin

Conversation

@kkaarreell
Copy link
Collaborator

@kkaarreell kkaarreell commented Feb 5, 2026

… 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:

  • Support parsing Jira issue keys with any uppercase project prefix instead of only RHEL-prefixed issues.
  • Display explicit error entries for Jira issues that are missing or access-restricted when fetching details in bulk.

Enhancements:

  • Clarify summarize helper docstrings to describe error entries in Jira issue data.

@kkaarreell kkaarreell self-assigned this Feb 5, 2026
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 5, 2026

Reviewer's Guide

Expands 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 handling

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Broaden Jira issue key parsing to accept any uppercase project prefix instead of only RHEL.
  • Update the regex used to extract Jira issues from comments to capture keys of the form -<4–8 digits> instead of just RHEL-
newa/cli/summarize_helpers.py
Allow formatting of Jira issue details to handle error-only entries alongside full issue data.
  • Document that jira_issues_data may contain error entries with an 'error' message
  • Branch formatting logic to detect issues containing only an 'error' field and output an Issue/Error pair
  • Retain existing detailed formatting for fully populated issue records
newa/cli/summarize_helpers.py
Add explicit handling for Jira issues that are missing or access-restricted when fetching in bulk.
  • Document that fetch_jira_issues_bulk returns an 'error' dict for nonexistent or restricted issues
  • Track which issues are returned from Jira search_issues via a found_keys set
  • After processing results, mark any requested but not returned issue keys with a standardized not-found/restricted error message
newa/cli/commands/summarize_cmd.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

… 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>
@kkaarreell kkaarreell merged commit 964cda5 into main Feb 5, 2026
16 checks passed
@kkaarreell kkaarreell deleted the ks_jira_parsin branch February 5, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant