Using addSchemeAssociation breaks Jira UI

HI,
I’m trying to setup project with scriptrunner and I have the following code to setup Field Configuration Schemes:

import com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
def projectKey = “TEMP02NEW”
def projectKey2 = “TEMP01”
def srcProject = projectManager.getProjectObjByKey(projectKey)
def newprojectGV = projectManager.getProjectObjByKey(projectKey2)
FieldLayoutManager fieldLayoutManager = ComponentAccessor.getFieldLayoutManager()
FieldConfigurationScheme srcProjectFieldLayout = fieldLayoutManager.getFieldConfigurationScheme(srcProject);
log.error srcProjectFieldLayout.getName()
fieldLayoutManager.addSchemeAssociation(newprojectGV, srcProjectFieldLayout.getId())
FieldConfigurationScheme srcProjectFieldLayout2 = fieldLayoutManager.getFieldConfigurationScheme(newprojectGV);
log.error srcProjectFieldLayout2.getName()

In general this code works but after running it, in jira UI project settings summary I don’t see Fields sections, and I can’t display /plugins/servlet/project-config/TEMP02NEW/fields at all. so also I can’t change Field Configuration Schemes in normal way anymore and this affect whole jira not only this one porject.

Under /secure/admin/ViewFieldLayoutSchemes.jspa I can see that assigments is correct…

in the attachment there is a log of what I get when I try to open /plugins/servlet/project-config/TEMP02NEW/fields

2020-07-08 15:33:29,566 http-nio-8082-exec-19 DEBUG admin 933x2955x1 18vemvq 10.156.0.255,0:0:0:0:0:0:0:1 /plugins/servlet/project-config/TEMP02NEW/fields [c.atlassian.ozymandias.SafePluginPointAccess] Unable to run plugin code because of ‘java.lang.NullPointerException - null’.
java.lang.NullPointerException