ScriptRunner Behavior is called twice on UI Fragment "Constrained create issue dialog"

Reinhard Mayr July 17, 2024

JSW/JSM DC 9.12.8/5.12.8, ScriptRunner 8.32.0

I have a UI fragment of type "Create Constrained Issue Web Item". The preview show me this:

<web-item key='request-new-analysis' name='ScriptRunner generated web item - request-new-analysis' section='operations-restore' weight='10'>
  <label>Request New Analysis</label>
  <condition class='script://jiraHelper.project?.key == "TSD"&#13;&#10;jiraHelper.project.projectCategory.id == 10001  // "Service Desk"&#13;&#10;    &amp;&amp; issue.status.id == &apos;10101&apos;  // Waiting for Support'>
    <param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.jira.fragments.CreateConstrainedIssueWebItem"}' />
    <param name='£fragmentParameters' value='{"id":"675644f3-3e44-4826-a609-1c4c311fb5ee"}' />
  </condition>
  <styleClass>sr-create-bound-issue request-new-analysis </styleClass>
  <link linkId='request-new-analysis'>https://jira-test/secure/CreateIssue.jspa?pid=10201&amp;issuetype=10403</link>
</web-item>

I have a behavior with an initialization script. Here, I test the reason of why the behavior script is called.

If, and only if, the behavior is called because the UI fragment was used, then I see 2 entries in the execution history, just milliseconds apart, even in parallel. All other ways to raise the create issue screen lead only to a single call.

In the HTTP logs I can clearly see that 2 POST requests to the URL as in the UI fragment's preview are issued.

Can anyone explain why the create issue is called twice? How can I prevent this from happening?

Thanks in advance for your replies!

Reinhard

 

 

2 answers

1 accepted

1 vote
Answer accepted
Reinhard Mayr July 23, 2024

It appears to be a SR Bug: https://assist.adaptavist.com/browse/SRJIRA-7038

To date, there is no known workaround.

0 votes
Graham Twine
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2024

Hello @Reinhard Mayr

 

Have you concidered the evaluation logic that "If, and only if, the behavior is called because the UI fragment"?

 

An extreme infinite loop such as; only create a task if a task is created in the project would create tasks forever, or realistically until an OOME occurred.

The logic may be doing something similar to the above described scenario.

Reinhard Mayr July 17, 2024

@Graham Twine , thank you for your input.

I can rule out a loop, because the evaluation regarding the caller does not apply any changes. The POST request and all subsequent actions are issue twice and no further, and there is no OOME.

All I do is to check sequence of form fields and the value of behaviorContextId:

def keys = getFormContents().keySet().toArray()

if (behaviourContextId == "request-new-analysis") {
// coming from UI fragment by that name
log.warn("Create linked issue through UI fragment.")

} else if (keys.findIndexOf { it == "issueId" } < 0) {
// no issueId found: this seems to be a create screen
log.warn("create screen")

if (keys.findIndexOf { it == "summary" } < 0) {
// no summary field
log.warn("Create issue form w/o fields.")

} else if (keys.findIndexOf { it == "issuelinks" } < keys.findIndexOf { it == "summary" }) {
// issue links are before the summary
log.warn("Create linked issue form.")

} else {
log.warn("Create issue form with fields.")
}

} else {
// issueId is present: this is an edit, assign, or transition screen
log.warn("non-create screen")
}

Suggest an answer

Log in or Sign up to answer