OrderableField.updateValue fails if called in pre-create post function before issue creation in Jra 7.13.9

We are attempting to migrate a Jira Core server from 7.12.1 to 7.13.9 and are running into failures in some code that sets custom field values via OrderableField.updateValue() in a post function that fires before the “Creates the issue originally.” post function.

It works fine in 7.12.1 but in 7.13.9 it starting failing with null pointer exceptions:

2019-11-25 03:00:00,945 Caesium-1-4 ERROR matrix.automation     [c.m.p.jira.workflow.CommandExecutor] An error occurred in misc.task.na.create in a PreCreatePostFunction when working on issue null (Reference ID: F5UPBA4K) due to java.lang.NullPointerException: null value in entry: issue=null
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException: null value in entry: issue=null
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2203)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4739)
	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.getValuesForIssueId(EagerLoadingOfBizCustomFieldPersister.java:103)
	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.getValuesForTypeAndParent(EagerLoadingOfBizCustomFieldPersister.java:86)
	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.updateValues(OfBizCustomFieldValuePersister.java:151)
	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.updateValues(EagerLoadingOfBizCustomFieldPersister.java:61)
	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValues(OfBizCustomFieldValuePersister.java:108)
	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.createValues(EagerLoadingOfBizCustomFieldPersister.java:49)
	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValues(OfBizCustomFieldValuePersister.java:101)
	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.createValues(EagerLoadingOfBizCustomFieldPersister.java:43)
	at com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType.createValue(AbstractSingleFieldType.java:143)
	at com.atlassian.jira.issue.fields.ImmutableCustomField.createValue(ImmutableCustomField.java:693)
	at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(ImmutableCustomField.java:410)
	at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(ImmutableCustomField.java:396)
	<rest of the call stack is my own code>

We can modify the issue directly before the issue creation (E.g. issue.setDescription works); it’s just calls to OrderableField.updateValue that have started failing.

We assumed that perhaps it was unsafe to set these values before the issue is created so we moved the code to after the issue creation post function, but then found that our field changes are not being persisted, apparently due to the behavior described in this article: https://confluence.atlassian.com/jirakb/post-function-on-create-issue-transition-appears-to-not-work-718836210.html. Unfortunately, that article recommends changing the values before the issue creation post function, which is what we were doing in the first place!

Does anyone know how we can set custom fields before the issue creation post function?

In case of custom fields, you should call MutableIssue#setCustomFieldValue