Skip to content

Fix Jira sync: handle closed tickets and correct transition matching#1174

Open
10zingpd wants to merge 3 commits intomainfrom
claude/fix-jira-sync-closed-tickets
Open

Fix Jira sync: handle closed tickets and correct transition matching#1174
10zingpd wants to merge 3 commits intomainfrom
claude/fix-jira-sync-closed-tickets

Conversation

@10zingpd
Copy link
Contributor

Summary

  • Fix transition matching to check destination state name (not transition name), resolving the failure to close tickets like RSDK-8814
  • Tag already-closed tickets with the fix version instead of skipping them (matches RDK behavior)
  • Include resolution: Done in close transition payload
  • Add Jira release page URL to summary output

Test plan

  • Run the workflow against the next release and verify previously-failing tickets close correctly
  • Verify already-closed tickets get tagged with the fix version

🤖 Generated with Claude Code

- 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>
@10zingpd 10zingpd requested a review from a team as a code owner March 19, 2026 20:26
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>
Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Review

Three of the four changes are correct and well-motivated:

  • Transition matching on t["to"]["name"] (destination state) instead of t["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.

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

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

  1. fixVersions SET semantics on already-closed tickets (line 142) — The PUT fields.fixVersions call replaces all existing fix versions. For the new elif status == "Closed" branch, this silently erases any version recorded when the ticket was originally closed against an older release. Use update.fixVersions.add to append, or explicitly document the overwrite-is-intentional assumption.

  2. Missing HTTP status check before parsing transitions response (line 163) — A 403/404/network failure on the transitions GET will surface as an unhandled JSONDecodeError rather than a clean error message, aborting the whole run.

Looks good

  • Transition-matching bug fix (t["to"]["name"] vs t["name"]) is correct and directly addresses the described failure (RSDK-8814).
  • Refactoring set_fix_version out of set_fix_version_and_close cleanly 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>
@viambot
Copy link
Member

viambot commented Mar 19, 2026

👋 Thanks for requesting a review from the team!

We aim to review PRs within one business day. If this is urgent
or blocking you, please reach out in #team-sdk and
we'll prioritize it.

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

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() returns None on API failure; the else/skipped branch silently swallows those tickets without surfacing an error — a network blip during status fetch would mark a ticket as "skipped" with a confusing None status label.
  • No failure counter: set_fix_version_and_close / set_fix_version can return False, 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.

src/viam/gen/ — not modified ✅

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.

2 participants