Details
-
Bug
-
Status: Done
-
High
-
Resolution: Fixed
-
5.4.1
-
None
-
Sprint 38 - Next
-
2
Description
To reproduce:
- Create a custom web item without a condition script (the rest of the configuration can be however you want so long as it's valid).
- Run the Script Registry
Expected result: The web item isn't shown in the list of scripts.
Actual result: The script registry fails with the following error:
java.lang.NullPointerException: Cannot get property 'scripts' on null object at com.onresolve.scriptrunner.canned.jira.admin.ScriptRegistry$_getFragmentsInfo_closure7.doCall(ScriptRegistry.groovy:311) at com.onresolve.scriptrunner.canned.jira.admin.ScriptRegistry.getFragmentsInfo(ScriptRegistry.groovy:309) at com.onresolve.scriptrunner.canned.jira.admin.ScriptRegistry.doScript(ScriptRegistry.groovy:66)
Why it happens: ScriptRegistry.getScriptInfo(...) returns null instead of a ConfiguredItem object if the item in question doesn't have any script associated with it. ScriptRegistry.getFragmentsInfo() doesn't expect this and tries to access the scripts property of the returned value without doing a null check, causing the NPE.
How to solve: The simplest fix is probably to change getFragmentsInfo to use safe navigation on the scripts property: it's being used as a condition anyway so propagating the null doesn't matter. Doing it this way saves us from having to worry about breaking any contracts of getScriptInfo.