Modify Issue without a user

I’m trying to modify an issue, but getting a permission error when I pass null as the user. However, I can’t pass a valid user in, since I’m not running in a context where there is a user (basically a cron job). There isn’t any particular user who can be said to have ‘performed’ the action, so I’d rather just leave the user field empty, but not sure how to bypass the permissions issue.

Here’s my (partial) code at the moment

public void setCustomField(CustomField field, Issue issue, String value) {
      ApplicationUser user = null; // What do I put here instead of null?
      IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
      issueInputParameters.addCustomFieldValue(field.getId(), value);
      issueInputParameters.setSkipScreenCheck(true);
      issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(true, true);
      UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issue.getId(), issueInputParameters);	
     //....
}

IssueService (and most of the other *Service) enforces permissions (and other validations). In this case it’s that anonymous doesn’t have the rights to create issues.

The workaround is to use IssueManager or other service. Take a look at the source of IssueService to see what it is doing.