ScriptRunner executes script as random other user instead of current user?

Hi everyone,

I recently got a report from a user that they get an error while trying to execute a certain function that triggers a ScriptRunner validator. When I looked into the logs, I figured that the groovy script wasn’t executed by that user, but instead a random different user with lower rights, who wasn’t allowed to access the project, therefore the script execution ran into an error. When checking the logs I found more occurrences with seemingly random combinations of one user triggering and a different user executing the script. I don’t see how this can happen? Anyone experienced the same?

I think I could make sure everything gets executed by an automation user, but I’m still puzzled about that behavior.

some scripts might be using things like ComponentAccessor.jiraAuthenticationContext.setLoggedInUser or something like that to override the currently logged in user. I’d absolutely avoid EVER setting the logged in user like that.

I have already checked if there is something that sets a user in those affected scripts but that’s not the case. From what I can say it also seems to happen infrequently.

I would suggest you check all scripts – Any script running in the same thread concurrently could override the user, right?

I looked everything up and only found some rare usages where it switches to a bot user to perform a certain action. I think I’ll change the actor to that user on the affected rules and take the jiraAuthenticationContext.setLoggedInUser it out. I don’t fully understand why it’s random other users yet but hopefully it fixes the issue. Thank you again.

1 Like

Good luck, I hope it’s as simple as that.