Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-24480

Cannot run automation subchain with parameters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 9.10
    • Fix Version/s: 9.10-HF05, 10.2
    • Component/s: Automation
    • Release Notes Summary:
      Parameters are taken into account when running Automation subchains.
    • Backlog priority:
      500
    • Impact type:
      API change
    • Upgrade notes:
      Hide

      In OperationContext:

      • Removed void push(Map<String, ?> map)
      • Removed void pop(Map<String, ?> map)
      • Changed
        Object push(String type, Object obj) to
        void push(String type, Object obj)
      • Removed boolean containsKey(Object key)
      • Added Map<String, Object> getChainParameters()
      • Added Map<String, Object> putChainParameters(Map<String, ?> parameters)
      • Added Map<String, Object> removeChainParameters()
      • Added Object getChainParameter(String key)
      • Added T callWithChainParameters(Callable<T> callable, Map<String, Object> parameters)
      • Added T callWithContextVar(Callable<T> callable, String key, Object value)
      Show
      In OperationContext: Removed void push(Map<String, ?> map) Removed void pop(Map<String, ?> map) Changed Object push(String type, Object obj) to void push(String type, Object obj) Removed boolean containsKey(Object key) Added Map<String, Object> getChainParameters() Added Map<String, Object> putChainParameters(Map<String, ?> parameters) Added Map<String, Object> removeChainParameters() Added Object getChainParameter(String key) Added T callWithChainParameters(Callable<T> callable, Map<String, Object> parameters) Added T callWithContextVar(Callable<T> callable, String key, Object value)
    • Sprint:
      nxfit 10.2.1, nxfit 10.2.2
    • Story Points:
      5

      Description

      1. install 9.10 (same with HF01)
      2. create a simple chain named hohoChain:
        - Context.FetchDocument
        
      3. create a chain calling this one:
        - Context.FetchDocument
        - Context.SetVar
            name: validationMode
            value: foo
        - RunOperation:
            id: hohoChain
            isolate: "false"
            parameters:
              validationMode: iauzyeiuaze
        
      4. add a User actions button (JSF ui for example)
      5. log into the web interface and click the button
      6. this generates the following stack:
        2018-02-22 16:07:31,222 WARN  [http-nio-0.0.0.0-8080-exec-11] [org.nuxeo.ecm.automation.core.trace.Trace] 
        
        ****** chain ******
        Name: runSubChain
        Exception: OperationException
        Caught error: Failed to invoke operation RunOperation with aliases [Context.RunOperation]
        Caused by: org.nuxeo.ecm.automation.OperationException: Failed to invoke operation RunOperation with aliases [Context.RunOperation]
        ****** Hierarchy calls ******
        	org.nuxeo.ecm.automation.core.operations.FetchContextDocument
        		org.nuxeo.ecm.automation.core.operations.SetVar
        			org.nuxeo.ecm.automation.core.operations.SetVar
        				org.nuxeo.ecm.automation.core.operations.SetVar
        					org.nuxeo.ecm.automation.core.operations.execution.RunOperation
        
        2018-02-22 16:07:31,222 ERROR [http-nio-0.0.0.0-8080-exec-11] [org.nuxeo.ecm.automation.jsf.OperationActionBean] Failed to execute action: 
        org.nuxeo.ecm.automation.OperationException: Failed to invoke operation RunOperation with aliases [Context.RunOperation]
        	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:188)
        	at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$OperationMethod.invoke(OperationChainCompiler.java:128)
        	at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$OperationMethod.invoke(OperationChainCompiler.java:135)
        	at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$OperationMethod.invoke(OperationChainCompiler.java:135)
        	at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$OperationMethod.invoke(OperationChainCompiler.java:135)
        	at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$OperationMethod.invoke(OperationChainCompiler.java:135)
        	at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$CompiledChainImpl.invoke(OperationChainCompiler.java:196)
        	at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.run(OperationServiceImpl.java:119)
        	at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.run(OperationServiceImpl.java:91)
        	at org.nuxeo.ecm.automation.jsf.OperationActionBean.runOperation(OperationActionBean.java:94)
        	at org.nuxeo.ecm.automation.jsf.OperationActionBean.doOperation(OperationActionBean.java:69)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:498)
        	at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
        	at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
        	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
        	at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
        	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        	at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:79)
        	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        	at org.nuxeo.ecm.platform.ui.web.util.NuxeoExceptionInterceptor.aroundInvoke(NuxeoExceptionInterceptor.java:80)
        	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        	at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
        	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
        	at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:196)
        	at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:114)
        	at org.nuxeo.ecm.automation.jsf.OperationActionBean_$$_javassist_seam_80.doOperation(OperationActionBean_$$_javassist_seam_80.java)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:498)
        	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
        	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
        	at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
        	at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
        	at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
        	at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
        	at org.nuxeo.ecm.platform.ui.web.binding.MetaMethodExpression.invoke(MetaMethodExpression.java:140)
        	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
        	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
        	at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.broadcast(UIValueHolder.java:95)
        	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
        	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
        	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
        	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
        	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
        	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
        	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
        	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
        	at org.nuxeo.elasticsearch.web.sync.UIThreadMarker.doFilter(UIThreadMarker.java:48)
        	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
        	at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoThreadTrackerFilter.doFilter(NuxeoThreadTrackerFilter.java:43)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoStandbyFilter.doFilter(NuxeoStandbyFilter.java:67)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.core.management.jtajca.internal.Log4jWebFilter.doFilter(Log4jWebFilter.java:69)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.ui.web.rest.FancyURLFilter.doFilter(FancyURLFilter.java:120)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoRequestControllerFilter.doFilter(NuxeoRequestControllerFilter.java:146)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.webdav.service.WIRequestFilter.doFilter(WIRequestFilter.java:61)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.ui.web.auth.NuxeoAuthenticationFilter.doFilterInternal(NuxeoAuthenticationFilter.java:615)
        	at org.nuxeo.ecm.platform.ui.web.auth.service.NuxeoAuthFilterChain.doFilter(NuxeoAuthFilterChain.java:51)
        	at org.nuxeo.ecm.platform.ui.web.auth.oauth.NuxeoOAuthFilter.doFilter(NuxeoOAuthFilter.java:122)
        	at org.nuxeo.ecm.platform.ui.web.auth.service.NuxeoAuthFilterChain.doFilter(NuxeoAuthFilterChain.java:49)
        	at org.nuxeo.ecm.platform.oauth2.NuxeoOAuth2Filter.doFilter(NuxeoOAuth2Filter.java:79)
        	at org.nuxeo.ecm.platform.ui.web.auth.service.NuxeoAuthFilterChain.doFilter(NuxeoAuthFilterChain.java:49)
        	at org.nuxeo.ecm.platform.ui.web.auth.NuxeoAuthenticationFilter.doFilter(NuxeoAuthenticationFilter.java:410)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoCorsFilter.doFilter(NuxeoCorsFilter.java:51)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.web.common.exceptionhandling.NuxeoExceptionFilter.doFilter(NuxeoExceptionFilter.java:67)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.nuxeo.ecm.platform.web.common.encoding.NuxeoEncodingFilter.doFilter(NuxeoEncodingFilter.java:75)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
        	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
        	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
        	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        	at java.lang.Thread.run(Thread.java:748)
        	Suppressed: java.lang.Throwable: 
        
        ****** chain ******
        Name: runSubChain
        Exception: OperationException
        Caught error: Failed to invoke operation RunOperation with aliases [Context.RunOperation]
        Caused by: org.nuxeo.ecm.automation.OperationException: Failed to invoke operation RunOperation with aliases [Context.RunOperation]
        ****** Hierarchy calls ******
        	org.nuxeo.ecm.automation.core.operations.FetchContextDocument
        		org.nuxeo.ecm.automation.core.operations.SetVar
        			org.nuxeo.ecm.automation.core.operations.SetVar
        				org.nuxeo.ecm.automation.core.operations.SetVar
        					org.nuxeo.ecm.automation.core.operations.execution.RunOperation
        
        		at org.nuxeo.ecm.automation.core.trace.TracerFactory.onTrace(TracerFactory.java:198)
        		at org.nuxeo.ecm.automation.core.trace.Tracer.popContext(Tracer.java:73)
        		at org.nuxeo.ecm.automation.core.trace.Tracer.onChainExit(Tracer.java:86)
        		at org.nuxeo.ecm.automation.core.impl.OperationChainCompiler$CompiledChainImpl.invoke(OperationChainCompiler.java:206)
        		... 112 more
        Caused by: java.lang.IllegalStateException: validationMode is not a stack
        	at org.nuxeo.ecm.automation.OperationContext.push(OperationContext.java:171)
        	at java.util.HashMap.forEach(HashMap.java:1289)
        	at org.nuxeo.ecm.automation.OperationContext.push(OperationContext.java:153)
        	at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.run(OperationServiceImpl.java:104)
        	at org.nuxeo.ecm.automation.core.operations.execution.RunOperation.run(RunOperation.java:59)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:498)
        	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:166)
        	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:178)
        	... 118 more
        

      This is due to this commit:
      https://github.com/nuxeo/nuxeo/commit/c5f49829af2f51a9f7de333ed3be86f59a366135#diff-b152f0823f4e02c157296735fce27162
      And especially this:
      https://github.com/nuxeo/nuxeo/blob/9.10/nuxeo-features/nuxeo-automation/nuxeo-automation-core/src/main/java/org/nuxeo/ecm/automation/OperationContext.java#L170

      While doing a debugging session the stack variable is indeed null and the variable is present in the vars map contains the variables, leading to the issue.

      Please note this was working fine before 9.10.
      -----------------------------------------------------------------------------

      History

      A lot of code was refactored with NXP-21293 to allow Automation scripting running thread-safe.
      In particular some changes in the OperationServiceImpl#run methods, see https://github.com/nuxeo/nuxeo/commit/6c1ab9ee6a08625f88d1e38e16c455116afdbe63#diff-9f404143f526ca4d99d77e5683fd7ff7L106
      Consequently, because of a missing merge, the chain parameters passed at runtime could be lost.

      Thus, the drag and drop issue NXP-21508 due to the "category" chain parameter sent in the request being lost.
      The fix was to flatten the chain parameters in the global OperationContext, whereas they were originally stored as a dedicated key "ChainParameters" of the global context, see initial implementation done for NXP-11096.
      See https://github.com/nuxeo/nuxeo/commit/c5f49829af2f51a9f7de333ed3be86f59a366135 and especially https://github.com/nuxeo/nuxeo/commit/c5f49829af2f51a9f7de333ed3be86f59a366135#diff-b152f0823f4e02c157296735fce27162R159 causing the current issue because of a misuse of the OperationContext stacks, originally designed to stack document(s) or (blob)s, not chain parameters.

      The fix consists in going back to the initial implementation by distinguishing the global context variables stored in the OperationContext ctx from the chain parameters stored as a map associated to a dedicated key in the global context map: (Map<String, Object>)ctx.get("ChainParameters").
      Variables and stacks and are now independent again in the OperationContext.
      Therefore, we allow the same key for a context variable and a chain parameter.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 days, 4 hours
                  4d 4h

                    PagerDuty

                    Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.