Unable to Edit Watchers for an Issue

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When a user tries to edit the Watchers field when viewing an issue, the process never end and thus, the user is unable to edit it.  This also manifests with being able to remove the watcher and seeing it successfully remove but upon hitting refresh the watcher is still on the issue.

In the atlassian-jira.log will show the following error message:

2013-10-31 09:07:37,557 http-80-21 ERROR xxxx 547x111484x1 xxx xx.xx.xxx.xx /secure/QuickEditIssue.jspa [jira.bc.issue.DefaultIssueService] Exception occurred editing issue: java.lang.NullPointerException
java.lang.NullPointerException
	at com.burningcode.jira.issue.customfields.impl.WatcherFieldType.getChangelogValue(WatcherFieldType.java:207)
	at com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType.getChangelogValue(AbstractMultiCFType.java:43)
	at com.atlassian.jira.issue.fields.CustomFieldImpl.getChangelogValue(CustomFieldImpl.java:378)

Cause

A user who happens to watch this particular issue has been deleted.  This scenario can happen when:

  1. JIRA uses an external user management, for example LDAP.
  2. The user in LDAP watches an issue.
  3. The LDAP admin delete this user from the LDAP.
  4. JIRA then synchronizes with the LDAP server.

This user does not exist in JIRA any-more, but the association of this user with an issue as a watcher still exist.

Workaround

One workaround is to delete these values (the association of this user from watching) directly from the database.

It is always safe to do this modification on a test instance or have an extra XML backup before proceeding with the suggestion.

  1. Shutdown your JIRA instance.
  2. Run the following SQL command on the database to identify the deleted users that are watchers:

    SELECT * FROM userassociation WHERE association_type = 'WatchIssue' AND source_name NOT IN (SELECT user_name FROM cwd_user);
  3. The above result should give the username along with the issue ID (note this ID is not the issue key, but rather the ID) and etc.

  4. Remove these users from the database by running the following SQL command on the database:

    DELETE FROM userassociation WHERE source_name = '<INSERT-USER-NAME-HERE>';
  5. Start JIRA again and Re-index.

Resolution

  1. Run the following SQL command on the database to update the jiraissue table to the correct number of watchers:

    UPDATE jiraissue i
    SET watches = 
    (SELECT COUNT(*) 
    FROM userassociation
    WHERE association_type = 'WatchIssue' 
    AND userassociation.sink_node_id = i.id );
Last modified on May 3, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.