Workflow post function Update Issue Custom Field value %%CURRENT_USER%% won't work if user has ever been renamed

XMLWordPrintable

    • 8
    • Severity 3 - Minor

      If a user had their user_name changed, the post function Update Issue Field won't set a user picker custom field to %%CURRENT_USER%%.

      Steps to reproduce

      1. Create a User: Charlie
      2. Change their user_name to Atlassian. This will cause the user_name to be different from the user_key;
      3. Create a user picker custom field and associate it to the project;
      4. Add the post function Update Issue Custom Field to a workflow transition, updating the value of this field to %%CURRENT_USER%%;
      5. Log in as the user Atlassian;
      6. Transition an issue to trigger the post function.

      Expected results

      The custom field value should be set to the user that transitioned the issue.

      Actual result

      The field remains empty after the transition.

      Stack trace

      java.lang.IllegalStateException: You cannot create a change item without either a 'from' or 'to' value.
      	at com.atlassian.jira.issue.history.ChangeItemBean$Builder.build(ChangeItemBean.java:387)
      	at com.atlassian.jira.issue.changehistory.AbstractChangeHistoryUserMapper.buildChangeItemBeanForUserField(AbstractChangeHistoryUserMapper.java:230)
      	at com.atlassian.jira.issue.changehistory.AbstractChangeHistoryUserMapper.buildChangeItemBean(AbstractChangeHistoryUserMapper.java:176)
      	at com.atlassian.jira.issue.changehistory.AbstractChangeHistoryUserMapper.lambda$buildChangeItemBeans$10(AbstractChangeHistoryUserMapper.java:194)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
      	at com.atlassian.jira.issue.changehistory.AbstractChangeHistoryUserMapper.buildChangeItemBeans(AbstractChangeHistoryUserMapper.java:195)
      	at com.atlassian.jira.issue.changehistory.ChangeHistory.lambda$getChangeItemBeans$0(ChangeHistory.java:170)
      	at com.atlassian.workcontext.metrics.Timer.time(Timer.java:171)
      	at com.atlassian.jira.issue.changehistory.ChangeHistory.getChangeItemBeans(ChangeHistory.java:169)
      	at com.atlassian.jira.rest.v2.issue.builder.ChangelogBeanBuilder.buildChangeHistoryBean(ChangelogBeanBuilder.java:105)
      	at com.atlassian.jira.rest.v2.issue.builder.ChangelogBeanBuilder.buildChangeHistoryBean(ChangelogBeanBuilder.java:159)
      	at com.atlassian.jira.rest.v2.issue.builder.ChangelogBeanBuilder.lambda$buildForMostRecentChangeByUser$15(ChangelogBeanBuilder.java:279)
      	at java.util.Optional.map(Optional.java:215)
      	at com.atlassian.jira.rest.v2.issue.builder.ChangelogBeanBuilder.buildForMostRecentChangeByUser(ChangelogBeanBuilder.java:277)
      	at com.atlassian.jira.plugins.webhooks.serializer.IssueEventSerializer.getChangelog(IssueEventSerializer.java:119)
      	at com.atlassian.jira.plugins.webhooks.serializer.IssueEventSerializer.putFields(IssueEventSerializer.java:84)
      	at com.atlassian.jira.plugins.webhooks.serializer.IssueEventSerializer.putFields(IssueEventSerializer.java:41)
      	at com.atlassian.jira.plugins.webhooks.serializer.AbstractJiraEventPropertyExtractingSerializer.createBaseSerializedEvent(AbstractJiraEventPropertyExtractingSerializer.java:33)
      	at com.atlassian.webhooks.plugin.WebHookPublisherImpl.lambda$publish$2(WebHookPublisherImpl.java:171)
      	at com.atlassian.jira.issue.fields.rest.json.beans.JiraBaseUrlsImpl.withRestApiV2Url(JiraBaseUrlsImpl.java:154)
      	at sun.reflect.GeneratedMethodAccessor2231.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at com.sun.proxy.$Proxy272.withRestApiV2Url(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor2231.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor$1.run(ServiceTCCLInterceptor.java:61)
      	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:130)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokePrivileged(ServiceTCCLInterceptor.java:58)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:50)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      	at com.sun.proxy.$Proxy1552.withRestApiV2Url(Unknown Source)
      	at com.atlassian.webhooks.plugin.WebHookPublisherImpl.publish(WebHookPublisherImpl.java:171)
      	at com.atlassian.webhooks.plugin.WebHookEventsProcessor.lambda$doOnEvent$0(WebHookEventsProcessor.java:108)
      	at com.atlassian.workcontext.api.WorkContextFunctionWrapper.lambda$withContext$0(WorkContextFunctionWrapper.java:43)
      	at com.atlassian.workcontext.api.WorkContextFunctionWrapper.lambda$withContext$7(WorkContextFunctionWrapper.java:117)
      	at com.atlassian.workcontext.api.WorkContextFunctionWrapper.lambda$withContext$1(WorkContextFunctionWrapper.java:49)
      	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      

      Workaround

      None.

            Assignee:
            Harold Ponting
            Reporter:
            Victor Romero
            Votes:
            3 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: