Details
-
Bug
-
Status: To Do
-
Trivial
-
Resolution: Unresolved
-
None
-
None
-
None
-
2.3
Description
In Script Console, when you write a script to get the Select List (cascading) field and its values, the Static Type Checking errors/warnings disappear and some errors are shown in the logs & HAR file.
Steps to Reproduce
- Copy and paste the following script into the Script Console:
import com.atlassian.jira.component.ComponentAccessor def issue = ComponentAccessor.getIssueManager().getIssueObject("SUN-3") // undeclared variable to trigger error issue4 // If I enter a Text Field def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10000") def fieldValue = issue.getCustomFieldValue(field) if(fieldValue.toString().contains("Yes")){ log.warn "YES" }
- Hover your mouse over the issue4 variable, you will see the Static Type Checking warning - "[Static type checking] - The variable [issue4] is undeclared.".
- Create a Jira's Select List (cascading) custom field.
- Modify the script in Script Console to replace the "customfield_10000" with the Select List (cascading) custom field id (i.e. customfield_10200):
// If I enter a Select List (cascading) field def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10200") def fieldValue = issue.getCustomFieldValue(field)
Expected Behaviour
The Static Type Checking warnings or errors should display for the undeclared variable - issue4.
Actual Behaviour
The Static Type Checking warnings or errors are not showing.
Workarounds
To cast the field value to a Map:
// If I enter a Select List (cascading) field def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10200") def fieldValue = issue.getCustomFieldValue(field) as Map
Additional Information
- I attached a demonstration video for reference: Screen Recording 2022-11-07 at 3.40.48 PM.mov
- I was able to reproduce the issue since ScriptRunner version 6.52.1.
- The following is shown in the first line of the script:
Failed type checking. Not all types of code can be checked, so this doesn't mean your script is not valid.
- The HAR file shows the 500 error for the requests below:
- The following stack trace is shown in the atlassian-jira.log:
2022-11-07 15:28:40,157+0800 http-nio-9093-exec-1 WARN admin 928x246x1 1qiog4s 0:0:0:0:0:0:0:1 /rest/scriptrunner/latest/codeinsight/check [c.o.s.stc.typecheck.TypeCheckingService] Failed type checking for import com.atlassian.jira.component.ComponentAccessor def issue = ComponentAccessor.getIssueManager().getIssueObject("SUN-3") // undeclared variable to trigger error issue4 // if I enter a Cascading select list def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10200") def fieldValue = issue.getCustomFieldValue(field) if(fieldValue.toString().contains("Yes")){ log.warn "YES" } isFile: false and we don't know why, it's our fault not yours BUG! exception in phase 'instruction selection' in source unit 'script1667806120039580541035.groovy' Expected earlier checking to detect generics parameter arity mismatch Expected: java.util.Map<K,V> Supplied: java.util.Map<com.atlassian.jira.issue.customfields.option.Option>