Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

green icon showed on a failure execution in the execution history of the validator

Bo Liu September 9, 2021

we have a Custom script validator, it does report failure from the frontend that the enduser failed the validation of a input of a field, but from the backend of the execution history, it supposed to be show a failure(red) icon but instead it shows success(green icon) on the execution. this is the snippet in scriptrunner how it throw error

errMsg = "The Planned for release does not have valid format. Please contact release leader"
log.error errMsg
throw new InvalidInputException("customfield_18038", errMsg)

the icon on the execution is supposed to be red, but it shows always green. we see this after we upgraded the jira to this version: v8.13.10#813010-sha1:156ab00

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
September 10, 2021

I am not sure if I am understanding the question properly, but if I am, then I think there is a misunderstanding about what the Scriptrunner execution status is telling us.

When a validator runs, it can do one of three things:

  • Return "yes, this is ok" back to Jira
  • Return "No, this is not valid" back to Jira, with an error message.  This is what your validator is doing when you use the "throw new InvalidInputException" line in your code
  • Go wrong and return either nothing or stuff Jira is not expecting and hence cannot handle

So, the Scriptrunner indicator is looking at whether the validator worked.  It is not looking at the results of the validation, it does not care if the validation passed or failed - both "yes" and "no + invalidinputexception" returns from the validator are valid and expected responses that means the script worked.

The Scriptrunner indicator tells you if the validator threw an error - if it crashes or fails and does not return either of the two expected responses.  Yours is showing green because the script is working ok

Bo Liu September 13, 2021

if the validator excution would still be regarded as "pass" even there's an exception thrown as in my case, so is there a way to show red icon on the validator execution for an exception?

Nic Brough -Adaptavist-
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.
September 13, 2021

No, that is not what the indicator is for.  As I said, the flag is telling you whether the script worked or not, not whether the validation failed.

Jira tells the user that the validation failed.

Suggest an answer

Log in or Sign up to answer