Skip to content

[BUG] jira_watchers: crash copying parent watchers (Jira Cloud uses accountId, not key) #744

Closed

Description

@sadsfae

Problem

src/quads/tools/jira_watchers.py crashes when copying watchers from a parent ticket to an extension/expansion ticket. The tool reads watcher["key"] but Jira Cloud returns no key field, raising KeyError. When run via cron it fails on the first ticket with a parent, so no parent watchers are copied to any EXTENSION/EXPANSION ticket.

Prod traceback (verbatim):

INFO - Google Chat notifier initialized
INFO - Hardware dispatcher loaded 1 plugins: ['badfish']
INFO - Provisioner dispatcher loaded 1 plugins: ['foreman']
INFO - Switch dispatcher loaded 1 plugins: ['juniper']
INFO - Email dispatcher loaded 1 plugins: ['email']
INFO - Post successful.
INFO - cloud14 labeled CAN_EXTEND
Traceback (most recent call last):
  File "/usr/lib/python3.14/site-packages/quads/tools/jira_watchers.py", line 104, in <module>
    err = loop.run_until_complete(main())
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
  File "/usr/lib/python3.14/site-packages/quads/tools/jira_watchers.py", line 75, in main
    response = await jira.add_watcher(ticket_key, watcher["key"])
                                                  ~~~~~~~^^^^^^^

Root cause

The loop in jira_watchers.py (lines 74-80) indexes watcher objects by "key":

for watcher in watchers["watchers"]:
    response = await jira.add_watcher(ticket_key, watcher["key"])
    if not response:
        failed_watchers.append(watcher["key"])

Jira Cloud GET /rest/api/2/issue/{issueIdOrKey}/watchers returns watcher user objects containing accountId, displayName, emailAddress, self, active, timeZone, and accountType — but no key field. This is a regression: the 2.2 branch of the same file used watcher["accountId"] for both the add_watcher call and the failed_watchers append.

Proposed fix

Minimal change restoring the 2.2 behavior in src/quads/tools/jira_watchers.py:

  • jira.add_watcher(ticket_key, watcher["key"]) → jira.add_watcher(ticket_key, watcher["accountId"])
  • failed_watchers.append(watcher["key"]) → failed_watchers.append(watcher["accountId"])

POST /rest/api/2/issue/{issueIdOrKey}/watchers expects the account ID as the JSON body; the current Jira client add_watcher already sends the raw value, so passing watcher["accountId"] (a string) is correct and no client change is needed.

Acceptance criteria

  1. jira_watchers.py no longer raises on watcher["key"] when a parent ticket has watchers.
  2. Watcher account IDs from the parent ticket are added to the extension/expansion ticket.
  3. 2.2 behavior (accountId) is restored; no change to the Jira client is needed.

Environment notes

  • Instance type: Jira Cloud (Atlassian), not Jira Server.
  • Plugin config: auth_type basic, URL .../rest/api/2, ticket_queue SCALELAB.
  • Installed prod copy: /usr/lib/python3.14/site-packages/quads/tools/jira_watchers.py (matches repo).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions