Fix: Clear old issues for KEEP/UPDATE when current newa_id found#354
Merged
Conversation
When on_respin is set to KEEP or UPDATE and NEWA finds both: - An issue with the current newa_id (which gets re-used) - Old open/closed issues from previous respins with outdated newa_ids The old issues were incorrectly being passed to _close_old_issues(), which expects to only receive issues when on_respin is CLOSE. This caused an "Invalid respin action" exception. Changes: - Added logic to clear old_opened_issues and old_closed_issues when new_issues is found for KEEP/UPDATE actions - Added warning log for old open issues to alert users about potential orphaned issues that may need manual cleanup - Added debug log for old closed issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts Jira issue handling for KEEP/UPDATE respin actions so that only issues tied to the current newa_id are processed, clearing outdated issues and adding logging for potential manual cleanup. Sequence diagram for KEEP/UPDATE respin issue handling with current newa_idsequenceDiagram
actor User
participant NewaCli
participant JiraHelpers
participant JiraApi
participant Logger
User->>NewaCli: run_newa_with_on_respin_KEEP_or_UPDATE()
NewaCli->>JiraHelpers: _find_or_create_issue(ctx, action, newa_id)
JiraHelpers->>JiraApi: search_issues_by_newa_id(current_newa_id)
JiraApi-->>JiraHelpers: new_issues_with_current_newa_id
alt existing_issue_closed
JiraHelpers->>JiraHelpers: reopen_issue(selected_issue)
JiraHelpers->>JiraHelpers: mark_selected_issue_as_new()
else existing_issue_open
JiraHelpers->>JiraHelpers: mark_selected_issue_as_new()
end
JiraHelpers->>JiraHelpers: new_issues.append(selected_issue)
JiraHelpers->>JiraHelpers: old_closed_issues = []
alt action_on_respin_is_KEEP_or_UPDATE
JiraHelpers->>JiraHelpers: detect_old_opened_issues_with_old_newa_id()
alt old_opened_issues_not_empty
JiraHelpers->>Logger: warning(Found old open issue ids, will be ignored)
JiraHelpers->>JiraHelpers: old_opened_issues = []
end
JiraHelpers->>JiraHelpers: detect_old_closed_issues_with_old_newa_id()
alt old_closed_issues_not_empty
JiraHelpers->>Logger: debug(Ignoring old closed issue ids)
JiraHelpers->>JiraHelpers: old_closed_issues = []
end
end
JiraHelpers-->>NewaCli: return new_issues
NewaCli-->>User: continue_processing_without_invalid_respin_error()
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
else:block is attached to the precedingif(not shown here), but the comment inside assumesnew_issueswere found; consider making the condition explicit (e.g.if new_issues and action.on_respin in (...)) to avoid unintentionally changing control flow in other cases. - The warning/debug messages are quite long and repeat similar context; you might want to slightly shorten or factor shared phrasing to keep logs more readable while still conveying that old issues are being ignored for KEEP/UPDATE.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `else:` block is attached to the preceding `if` (not shown here), but the comment inside assumes `new_issues` were found; consider making the condition explicit (e.g. `if new_issues and action.on_respin in (...)`) to avoid unintentionally changing control flow in other cases.
- The warning/debug messages are quite long and repeat similar context; you might want to slightly shorten or factor shared phrasing to keep logs more readable while still conveying that old issues are being ignored for KEEP/UPDATE.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
When on_respin is set to KEEP or UPDATE and NEWA finds both:
The old issues were incorrectly being passed to _close_old_issues(), which expects to only receive issues when on_respin is CLOSE. This caused an "Invalid respin action" exception.
Changes:
🤖 Generated with Claude Code
Summary by Sourcery
Handle old JIRA issues correctly when reusing issues for a respin with KEEP or UPDATE actions.
Bug Fixes:
Enhancements: