When field not set, validator condition "Validation based on mathematical or date-time expression' throws exception preventing other conditions from succeeding

Issue #8 resolved
Matthew Williams created an issue

This is similar to issue #5, but this time in the transition validators. If any field that is being validated using the mathematical validation is not set, then an exception is thrown preventing any validation succeeding, rather than that validation just returning false.

As an example, if we have two fields, such as "field1" and "field2" that we want to validate in a transition. Field1 has a simple integer value that is set to zero, and field2 is a date field that has not yet been set (i,.e. is currently NULL).

In our flow if the value in field1 is set to non-zero, we want to validate the date in field2. If field1 is zero, then we don't care what the date is in field2. So we have a validation such as:

{50100} = 0 or {50702} <= {00057}

50100 represents field1 50702 represents field2 00057 is the current date and time.

If I then try and use this transition, rather than it succeeding as expected, because field1 is zero, an exception is thrown in the logs and the error below appears in the Jira screen:

Field "field2" is not set.

I think it would be more sensible for the validation of field2 to simply return false, as the condition isn't true if the field is NULL.

The exception is below.

2013-03-21 12:30:22,771 http-bio-8080-exec-162 ERROR mwilli3 750x685284x1 jpr3qr 10.83.194.44,10.82.34.58 /secure/CommentAssignIssue.jspa [plugins.workflowTo olbox.shared.MathCalculatorValueProvider] *** PROVIDED NULL VALUE FOR STRING 50702 DUE TO EXCEPTION class java.lang.NullPointerException 2013-03-21 12:30:22,771 http-bio-8080-exec-162 ERROR mwilli3 750x685284x1 jpr3qr 10.83.194.44,10.82.34.58 /secure/CommentAssignIssue.jspa [atlassian.jira.wor kflow.OSWorkflowManager] Caught exception while attempting to perform action 11 from workflow 75702 on issue 'CRS-457' [InvalidInputException: [Error map: [{}]] [Error list: [[Field "field2" is not set.]]] at com.fca.jira.plugins.workflowToolbox.MathExpressionsValidator.validate(MathExpressionsValidator.java:57) at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1512) at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203) at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:564) at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowActionInsideTxn(OSWorkflowManager.java:916) at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowAction(OSWorkflowManager.java:871) at com.atlassian.jira.bc.issue.DefaultIssueService.transition(DefaultIssueService.java:449) at com.atlassian.jira.web.action.issue.CommentAssignIssue.doExecute(CommentAssignIssue.java:196) at webwork.action.ActionSupport.execute(ActionSupport.java:165) at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:82) at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39) at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31) at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16) at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:35) at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:221) at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:150) at com.atlassian.jira.web.dispatcher.JiraWebworkActionDispatcher.service(JiraWebworkActionDispatcher.java:153) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.atlassian.jira.web.filters.XContentTypeOptionsNoSniffFilter.doFilter(XContentTypeOptionsNoSniffFilter.java:22) at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:44) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66) at com.atlassian.labs.botkiller.BotKillerFilter.doFilter(BotKillerFilter.java:36) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66) at com.atlassian.jira.tzdetect.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:39) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66) at com.atlassian.jira.baseurl.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:40) at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74) at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:25)

Comments (3)

  1. Fidel Castro Armario repo owner

    I have just released JIRA Workflow Toolbox 2.0.24 with a partial solution for this issue:

    Parser of logical expressions now implements a shortcut in logical operator "OR", with the same behavior as operator "||" in languages like C and JAVA. Let's suppose you have a logical expression like "A or B or C". The parser first evaluates term A, in case it is evaluated as true, it stops evaluating the formula and passes the validation; otherwise it evaluates term B, with the same behavior as before, and so on.

    This is not a whole solution for the issue, but if you can guess which fields are probably keept uninitialized, ordering the terms in your formula according to it should be a valid solution.

    Perhaps in a future version I will give a more complete solution to it.

  2. Log in to comment