Uploaded image for project: 'MidPoint'
  1. MidPoint
  2. MID-4812

ADD deltas for single-valued properties break mapping evaluation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7.2, 3.8
    • Fix Version/s: backlog
    • Component/s: None
    • Labels:
      None
    • Subscription:
      Active subscription

      Description

      When submitting ADD deltas for single-valued properties, mapping evaluation is broken.

      An example:

      User template with mapping:

      <objectTemplate oid="645d022f-c455-4ef6-8df8-320d5c4e9cf8" xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
      	<name>Basic User Template</name>
      	<mapping>
      		<strength>strong</strength>
      		<source>
      			<path>givenName</path>
      		</source>
      		<source>
      			<path>familyName</path>
      		</source>
          	<expression>
          		<script>
          			<code>
          				'This is ' + givenName + ' ' + familyName + '.'
          			</code>
          		</script>
          	</expression>
          	<target>
          		<path>description</path>
          	</target>
      	</mapping>
      </objectTemplate>
      

      Original user:

      <user oid="49d415a2-366e-4ea2-b7ce-be5fccd8f677">
      	<name>user</name>
      	<givenName>John</givenName>
      	<familyName>March</familyName>
      </user>
      

      Execution of ADD deltas for givenName and familyName: John -> Jack, March -> April

      <s:pipeline xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
          <s:expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="s:SearchExpressionType">
              <s:type>ObjectType</s:type>
              <s:searchFilter>
                  <q:inOid xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3">
                      <q:value>49d415a2-366e-4ea2-b7ce-be5fccd8f677</q:value>
                      <!-- user -->
                  </q:inOid>
              </s:searchFilter>
          </s:expression>
          <s:expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="s:ActionExpressionType">
              <s:type>modify</s:type>
              <s:parameter>
                  <s:name>delta</s:name>
                  <c:value xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" xsi:type="t:ObjectDeltaType" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
                      <t:itemDelta>
                          <t:modificationType>add</t:modificationType>
                          <t:path>givenName</t:path>
                          <t:value>Jack</t:value>
                      </t:itemDelta>
                      <t:itemDelta>
                          <t:modificationType>add</t:modificationType>
                          <t:path>familyName</t:path>
                          <t:value>April</t:value>
                      </t:itemDelta>
                  </c:value>
              </s:parameter>
          </s:expression>
      </s:pipeline>
      

      The result:

      com.evolveum.midpoint.model.api.ScriptExecutionException: Couldn't execute action 'modify' on POV:user:49d415a2-366e-4ea2-b7ce-be5fccd8f677(user): Couldn't modify object: Attempt to replace 4 values to a single-valued item description in object template objectTemplate:645d022f-c455-4ef6-8df8-320d5c4e9cf8(Basic User Template) for focus user:49d415a2-366e-4ea2-b7ce-be5fccd8f677(user); values: [PPV(String:This is John April.), PPV(String:This is Jack March.), PPV(String:This is Jack April.), PPV(String:This is John March.)]
      	at com.evolveum.midpoint.model.impl.scripting.actions.BaseActionExecutor.processActionException(BaseActionExecutor.java:128)
      	at com.evolveum.midpoint.model.impl.scripting.actions.ModifyExecutor.execute(ModifyExecutor.java:83)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.executeAction(ScriptingExpressionEvaluator.java:223)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.evaluateExpression(ScriptingExpressionEvaluator.java:202)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.evaluateExpression(ScriptingExpressionEvaluator.java:183)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.executePipeline(ScriptingExpressionEvaluator.java:232)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.evaluateExpression(ScriptingExpressionEvaluator.java:192)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.evaluateExpression(ScriptingExpressionEvaluator.java:170)
      	at com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator.evaluateExpression(ScriptingExpressionEvaluator.java:146)
      	at com.evolveum.midpoint.model.impl.controller.ModelController.evaluateExpression(ModelController.java:1997)
      	at com.evolveum.midpoint.model.impl.ModelRestService.executeScript(ModelRestService.java:931)
      	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.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179)
      	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
      	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:192)
      	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:103)
      	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
      	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
      	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
      	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
      	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
      	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
      	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
      	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:191)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
      	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
      	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.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:269)
      	at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)
      	at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at com.evolveum.midpoint.web.util.MidPointProfilingServletFilter.doFilter(MidPointProfilingServletFilter.java:86)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:208)
      	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
      	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
      	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115)
      	at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
      	at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108)
      	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:198)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
      	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:790)
      	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:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: com.evolveum.midpoint.model.api.ScriptExecutionException: Couldn't modify object: Attempt to replace 4 values to a single-valued item description in object template objectTemplate:645d022f-c455-4ef6-8df8-320d5c4e9cf8(Basic User Template) for focus user:49d415a2-366e-4ea2-b7ce-be5fccd8f677(user); values: [PPV(String:This is John April.), PPV(String:This is Jack March.), PPV(String:This is Jack April.), PPV(String:This is John March.)]
      	at com.evolveum.midpoint.model.impl.scripting.helpers.OperationsHelper.applyDelta(OperationsHelper.java:88)
      	at com.evolveum.midpoint.model.impl.scripting.actions.ModifyExecutor.execute(ModifyExecutor.java:79)
      	... 85 common frames omitted
      Caused by: com.evolveum.midpoint.util.exception.SchemaException: Attempt to replace 4 values to a single-valued item description in object template objectTemplate:645d022f-c455-4ef6-8df8-320d5c4e9cf8(Basic User Template) for focus user:49d415a2-366e-4ea2-b7ce-be5fccd8f677(user); values: [PPV(String:This is John April.), PPV(String:This is Jack March.), PPV(String:This is Jack April.), PPV(String:This is John March.)]
      	at com.evolveum.midpoint.prism.delta.ItemDelta.validate(ItemDelta.java:1004)
      	at com.evolveum.midpoint.model.impl.lens.projector.focus.ObjectTemplateProcessor.computeItemDeltas(ObjectTemplateProcessor.java:409)
      	at com.evolveum.midpoint.model.impl.lens.projector.focus.ObjectTemplateProcessor.processTemplate(ObjectTemplateProcessor.java:184)
      	at com.evolveum.midpoint.model.impl.lens.projector.focus.FocusProcessor.lambda$processFocusFocus$2(FocusProcessor.java:213)
      	at com.evolveum.midpoint.model.impl.lens.LensUtil.partialExecute(LensUtil.java:954)
      	at com.evolveum.midpoint.model.impl.lens.LensUtil.partialExecute(LensUtil.java:941)
      	at com.evolveum.midpoint.model.impl.lens.projector.focus.FocusProcessor.processFocusFocus(FocusProcessor.java:212)
      	at com.evolveum.midpoint.model.impl.lens.projector.focus.FocusProcessor.processFocus(FocusProcessor.java:124)
      	at com.evolveum.midpoint.model.impl.lens.projector.Projector.lambda$projectInternal$1(Projector.java:229)
      	at com.evolveum.midpoint.model.impl.lens.LensUtil.partialExecute(LensUtil.java:954)
      	at com.evolveum.midpoint.model.impl.lens.projector.Projector.projectInternal(Projector.java:227)
      	at com.evolveum.midpoint.model.impl.lens.projector.Projector.project(Projector.java:116)
      	at com.evolveum.midpoint.model.impl.lens.Clockwork.click(Clockwork.java:447)
      	at com.evolveum.midpoint.model.impl.lens.Clockwork.run(Clockwork.java:204)
      	at com.evolveum.midpoint.model.impl.controller.ModelController.executeChanges(ModelController.java:541)
      	at com.evolveum.midpoint.model.impl.controller.ModelController.executeChanges(ModelController.java:332)
      	at com.evolveum.midpoint.model.impl.scripting.helpers.OperationsHelper.applyDelta(OperationsHelper.java:85)
      	... 86 common frames omitted
      

      When using replace instead of add, everything works well.

      Obviously the following code should be invoked, but is not, because of the unusual delta:
      AbstractValueTransformationExpressionEvaluator.java:386

      			if (hasPlus && hasMinus) {
      				// The combination of values that are both in plus and minus. Evaluating this combination
      				// does not make sense. Just skip it.
      				// Note: There will NOT be a single value that is in both plus and minus (e.g. "replace with itself" case).
      				// That case is handled by the elseif branches above. This case strictly applies to
      				// combination of different values from the plus and minus sets.
      				return;
      			}
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mederly Pavol Mederly
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: