User lookup in Jira Cloud

I have this in an outging Exalate for Jira Cloud:

def find_user(accountid)
{
    def userObject = nodeHelper.getUser(accountid)
    if (userObject )
    {
        def fullName = userObject.displayName
        def email = userObject.email
        return fullName + " (" + email + ")"
    }
    return "Cloud not lookup: " + accountid
}
if (replica.comments)
{
    def pattern = /\[~accountid:([0-9]+:[0-9a-fA-F-]+)\]/
    replica.comments.each { comment ->
        def commentBody = comment.body
        def result = commentBody.replaceAll(pattern) { fullMatch, accountid ->
            find_user(accountid)
        }
        comment.body = result
    }
}

It works fine for my own user - both when I mention myself, or other mention me. But for the rest of the users it does not work.

We have tried to set email adress to be seen by “Anyone” on id.atlassian.com - but that did not help

The issue you’re experiencing is due to Atlassian’s privacy changes for Jira Cloud. Even if users set their email to be visible to “Anyone” on id.atlassian.com, Jira Cloud may still restrict access to user details (like email and displayName) via the API, especially for users other than yourself. This means nodeHelper.getUser(accountId) can return a user object for you, but null for others if Exalate doesn’t have permission to see their details.

Key points from the documentation:

  • For Jira Cloud, nodeHelper.getUser(accountId) returns a user object or null if the user isn’t found or is hidden due to privacy settings.
  • If user details are hidden, Exalate can’t retrieve email or displayName, regardless of the user’s own privacy settings.
  • This is a known limitation due to Atlassian’s privacy policy changes. See: getUser documentation and User Fields Don’t Sync.

Workarounds:

  • If you need to map users reliably, consider maintaining a manual mapping between accountIds and display names/emails for users whose details are hidden.
  • Example mapping approach (from the docs):
final def userMapping = [
  "557358:bda57a72g56a9-4219-9c29-7d666481388f": "John Doe (john@example.com)",
  // add more mappings as needed
]

def find_user(accountid) {
    return userMapping[accountid] ?: "Cloud not lookup: " + accountid
}

In summary: This is a Jira Cloud privacy limitation, not an Exalate bug. Manual mapping is the most reliable workaround for users whose details Exalate can’t access.