How to Identify Issues Assigned to Deleted Users in JIRA

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

    

The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.

We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!

Summary

The deletion of a user is an unadvised scenario — whenever possible you should aim to disable users instead of deleting them.

Exceptions may occur, though, like severe LDAP failure, misconfiguration or even intentionally disabling a directory can lead to users being deleted during the next synchronization, wiping out group memberships and project roles data, too.

This article provides a comprehensive solution for JIRA administrators and users facing challenges in identifying issues assigned to or reported by users whose accounts have been deleted from JIRA. Due to the limitations within JIRA's user interface and the absence of a direct JQL query to pinpoint these issues, this article introduces a practical workaround leveraging the JIRA REST API in conjunction with a custom bash script.

Example

For the following assignee was removed the user from the LDAP, and then Jira correctly set it as Inactive:

However, after disabling the entire user directory, now the Assignee shows lower case user name without any indication if it is active or not:

It's possible to search for the assignee in lower case but it is not possible to know issues with Assignees that are deleted using JQL.

Environment

Jira Software or Jira Service Management version 8+

Solution

The article outlines a step-by-step approach utilizing the REST API for issue search, specifically focusing on extracting issues where the assignee or reporter fields are null, indicating the original user has been deleted. A bash script is provided, which automates the process of querying JIRA for these issues, parsing the response to identify the relevant ones, and then compiling a list of issue keys for further action.

The script uses Basic Authentication and requires setting 3 parameters:

  1. username.
  2. password.
  3. base url.

It's also mandatory to install jq for parsing JSON.

get_issues_w_del_user.sh
#!/bin/bash

username=$1
password=$2
baseUrl=$3

startAt=0
maxResults=50
issues=()
noMoreData=false

while [ "$noMoreData" = false ]; do
    response=$(curl -s -u "$username:$password" -X GET "$baseUrl/rest/api/2/search?fields=assignee&expand=assignee&jql=assignee%20is%20not%20empty&startAt=$startAt&maxResults=$maxResults")

    nullAssigneeIssues=$(echo "$response" | jq -r '.issues[] | select(.fields.assignee == null) | .key')

    if [ -z "$nullAssigneeIssues" ]; then
        noMoreData=true
    else
        issues+=($nullAssigneeIssues)
        startAt=$((startAt + maxResults))
    fi
done

echo "The following issues have been detected deleted assignee users: ${issues[*]}"

noMoreData=false
issues=()

while [ "$noMoreData" = false ]; do
    response=$(curl -s -u "$username:$password" -X GET "$baseUrl/rest/api/2/search?fields=reporter&expand=assignee&jql=reporter%20is%20not%20empty&startAt=$startAt&maxResults=$maxResults")

    nullReporterIssues=$(echo "$response" | jq -r '.issues[] | select(.fields.reporter == null) | .key')

    if [ -z "$nullReporterIssues" ]; then
        noMoreData=true
    else
        issues+=($nullReporterIssues)
        startAt=$((startAt + maxResults))
    fi
done

echo "The following issues have been detected deleted reporter users: ${issues[*]}"

To execute the script:

bash get_issues_w_del_user.sh <user> <password> <base url>

And the expected output:

The following issues have been detected deleted assignee users: SCRUM-9 SCRUM-8
The following issues have been detected deleted reporter users:

Last modified on May 3, 2024

Was this helpful?

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