Fix Jira sync: handle closed tickets and correct transition matching#1174
Fix Jira sync: handle closed tickets and correct transition matching#1174
Conversation
- Fix transition matching to check destination state name instead of transition name, resolving failures when closing tickets - Add set_fix_version() to tag already-closed tickets with fix version instead of skipping them - Include resolution "Done" in close transition payload - Add Jira release page URL to summary output Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
set_fix_version_and_close was duplicating the fix-version PUT request that the new set_fix_version() helper encapsulates. Refactor step 1 to call set_fix_version() instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Review
Three of the four changes are correct and well-motivated:
- Transition matching on
t["to"]["name"](destination state) instead oft["name"](transition label) is the right fix. - Including
"resolution": {"name": "Done"}in the close payload is correct Jira practice. - The improved error message listing available transitions is genuinely useful for debugging.
Fixed directly
Code duplication (set_fix_version_and_close, step 1): the newly introduced set_fix_version() helper encapsulates the exact fix-version PUT logic, but set_fix_version_and_close was left with a full copy of that code (7 lines). I refactored step 1 to call set_fix_version() instead — see the follow-up commit.
Requires attention
set_fix_version replaces, not appends, fixVersions (etc/sync_jira_release.py, line 142):
update_payload = {"fields": {"fixVersions": [{"id": version_id}]}}A fields PUT replaces the entire fixVersions array. If a ticket was already closed and had a fix version from a prior release, running this script will silently overwrite it. The Jira API supports additive semantics via the update key:
update_payload = {"update": {"fixVersions": [{"add": {"id": version_id}}]}}This is safe to call even when the ticket has no existing fix versions. The replacement behavior affects both set_fix_version() (called for already-closed tickets) and the pre-existing set_fix_version_and_close() step (via the refactored call), so the fix should land in set_fix_version() itself.
Minor
get_ticket_status returns None on a non-200 HTTP response, but in main() the status value is compared against string literals without a null guard. If the Jira API returns an error (rate-limit, network blip, etc.), the ticket silently falls through to the else/skipped branch rather than surfacing an error. This was pre-existing, but worth noting.
There was a problem hiding this comment.
Code Review: Fix Jira sync — handle closed tickets and correct transition matching
The core fixes are correct and well-targeted. Two issues need attention before merging.
Must-fix
-
fixVersionsSET semantics on already-closed tickets (line 142) — ThePUT fields.fixVersionscall replaces all existing fix versions. For the newelif status == "Closed"branch, this silently erases any version recorded when the ticket was originally closed against an older release. Useupdate.fixVersions.addto append, or explicitly document the overwrite-is-intentional assumption. -
Missing HTTP status check before parsing transitions response (line 163) — A 403/404/network failure on the transitions GET will surface as an unhandled
JSONDecodeErrorrather than a clean error message, aborting the whole run.
Looks good
- Transition-matching bug fix (
t["to"]["name"]vst["name"]) is correct and directly addresses the described failure (RSDK-8814). - Refactoring
set_fix_versionout ofset_fix_version_and_closecleanly removes duplication. - Including
"resolution": {"name": "Done"}in the close-transition payload is correct for Jira API v3. - Improved error output showing available transitions aids future debugging.
src/viam/gen/was not modified.
- Use update.fixVersions.add instead of fields.fixVersions to append the fix version rather than replacing existing ones - Refactor set_fix_version_and_close to call set_fix_version() directly, removing the duplicated PUT logic - Add HTTP status check before parsing the transitions GET response Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
👋 Thanks for requesting a review from the team! We aim to review PRs within one business day. If this is urgent |
There was a problem hiding this comment.
Code Review — Follow-up round
Both blockers from the previous review rounds are now addressed:
- Additive fixVersions (
update.fixVersions.add): correctly appends rather than replacing, idempotent on re-runs. ✅ - HTTP status check on transitions GET: clean early-return with a diagnostic message. ✅
Remaining minor issue
etc/sync_jira_release.py, line 176 — the diagnostic available list uses t['name'] (bare key access) to build the label, but t.get('to', {}).get('name', '?') for the destination name. The Jira API has always included name on transitions in practice, so this won't blow up, but the inconsistency is worth noting (left an inline comment).
Pre-existing issues (not introduced by this PR, no change requested)
get_ticket_status()returnsNoneon API failure; theelse/skipped branch silently swallows those tickets without surfacing an error — a network blip during status fetch would mark a ticket as "skipped" with a confusingNonestatus label.- No failure counter:
set_fix_version_and_close/set_fix_versioncan returnFalse, but the summary only counts successes. A run with four silent failures would report clean totals.
Both of those pre-date this PR. They're worth filing follow-up tickets for but should not block this merge.
Summary
resolution: Donein close transition payloadTest plan
🤖 Generated with Claude Code