You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "njnu-seafish (via GitHub)" <gi...@apache.org> on 2025/10/14 07:33:55 UTC

[PR] [Fix-17575][Workflow] Add a check for duplicate task names when saving or updating a workflow. [dolphinscheduler]

njnu-seafish opened a new pull request, #17576:
URL: https://github.com/apache/dolphinscheduler/pull/17576

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are happy that you want to help us improve DolphinScheduler! -->
   
   ## Purpose of the pull request
   
   close #17575
   
   ## Brief change log
   
   Add a check for duplicate task names when saving or updating a workflow.
   
   
   ## Verify this pull request
   
   
   
   This change added tests and can be verified as follows:
   
   When creating tasks with the same name, a prompt message will be displayed.
   
   ## Pull Request Notice
   [Pull Request Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   
   If your pull request contains incompatible change, you should also add it to `docs/docs/en/guide/upgrade/incompatible.md`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17575][Workflow] Add a check for duplicate task names when saving or updating a workflow. [dolphinscheduler]

Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on PR #17576:
URL: https://github.com/apache/dolphinscheduler/pull/17576#issuecomment-3400506605

   **In the code, there are numerous Map data structures that use task names as key values.**
   
   > java.util.concurrent.CompletionException: java.lang.IllegalStateException: Duplicate key TaskDefinition(id=124, code=154336501540032, name=shell_01, version=1, description=, projectCode=148941944330592, userId=2, taskType=SHELL, taskParams={"localParams":[],"rawScript":"echo \"111\"","resourceList":[]}, taskParamList=[], taskParamMap=null, flag=YES, taskPriority=MEDIUM, userName=null, projectName=null, workerGroup=default, environmentCode=144873539254368, failRetryTimes=0, failRetryInterval=1, timeoutFlag=CLOSE, timeoutNotifyStrategy=null, timeout=0, delayTime=0, resourceIds=null, createTime=Sat Oct 11 10:33:35 GMT+08:00 2025, updateTime=Sat Oct 11 10:33:35 GMT+08:00 2025, modifyBy=null, taskGroupId=0, taskGroupPriority=0, cpuQuota=-1, memoryMax=-1, taskExecuteType=BATCH)
   	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
   	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
   	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1606)
   	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:750)
   Caused by: java.lang.IllegalStateException: Duplicate key TaskDefinition(id=124, code=154336501540032, name=shell_01, version=1, description=, projectCode=148941944330592, userId=2, taskType=SHELL, taskParams={"localParams":[],"rawScript":"echo \"111\"","resourceList":[]}, taskParamList=[], taskParamMap=null, flag=YES, taskPriority=MEDIUM, userName=null, projectName=null, workerGroup=default, environmentCode=144873539254368, failRetryTimes=0, failRetryInterval=1, timeoutFlag=CLOSE, timeoutNotifyStrategy=null, timeout=0, delayTime=0, resourceIds=null, createTime=Sat Oct 11 10:33:35 GMT+08:00 2025, updateTime=Sat Oct 11 10:33:35 GMT+08:00 2025, modifyBy=null, taskGroupId=0, taskGroupPriority=0, cpuQuota=-1, memoryMax=-1, taskExecuteType=BATCH)
   	at java.util.stream.Collectors.lambda$throwingMerger$0(Collectors.java:133)
   	at java.util.HashMap.merge(HashMap.java:1255)
   	at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
   	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
   	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
   	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:566)
   	at org.apache.dolphinscheduler.server.master.engine.graph.WorkflowGraph.<init>(WorkflowGraph.java:51)
   	at org.apache.dolphinscheduler.server.master.engine.graph.WorkflowGraphFactory.createWorkflowGraph(WorkflowGraphFactory.java:54)
   	at org.apache.dolphinscheduler.server.master.engine.command.handler.AbstractCommandHandler.assembleWorkflowGraph(AbstractCommandHandler.java:122)
   	at org.apache.dolphinscheduler.server.master.engine.command.handler.AbstractCommandHandler.handleCommand(AbstractCommandHandler.java:79)
   	at org.apache.dolphinscheduler.server.master.engine.workflow.runnable.WorkflowExecutionRunnableFactory.doCreateWorkflowExecutionRunnable(WorkflowExecutionRunnableFactory.java:71)
   	at org.apache.dolphinscheduler.server.master.engine.workflow.runnable.WorkflowExecutionRunnableFactory.createWorkflowExecuteRunnable(WorkflowExecutionRunnableFactory.java:56)
   	at org.apache.dolphinscheduler.server.master.engine.workflow.runnable.WorkflowExecutionRunnableFactory$$FastClassBySpringCGLIB$$597b7266.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:792)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762)
   	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
   	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:707)
   	at org.apache.dolphinscheduler.server.master.engine.workflow.runnable.WorkflowExecutionRunnableFactory$$EnhancerBySpringCGLIB$$c423f38c.createWorkflowExecuteRunnable(<generated>)
   	at org.apache.dolphinscheduler.server.master.engine.command.CommandEngine.lambda$bootstrapCommand$2(CommandEngine.java:153)
   	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
   	... 3 common frames omitted
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17575][Workflow] Add a check for duplicate task names when saving or updating a workflow. [dolphinscheduler]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #17576:
URL: https://github.com/apache/dolphinscheduler/pull/17576#discussion_r2428247686


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:
##########
@@ -459,12 +459,22 @@
     private List<TaskDefinitionLog> generateTaskDefinitionList(String taskDefinitionJson) {
         try {
             List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class);
+
             if (CollectionUtils.isEmpty(taskDefinitionLogs)) {
                 log.error("Generate task definition list failed, the given taskDefinitionJson is invalided: {}",
                         taskDefinitionJson);
                 throw new ServiceException(Status.DATA_IS_NOT_VALID, taskDefinitionJson);
             }
+
+            Set<String> taskNameSet = new HashSet<>();
             for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) {
+                if (!taskNameSet.add(taskDefinitionLog.getName())) {
+                    log.error(
+                            "Generate task definition list failed, the given task definition name is duplicate, taskName: {}, taskDefinition: {}",
+                            taskDefinitionLog.getName(), taskDefinitionLog);

Review Comment:
   ## Log Injection
   
   This log entry depends on a [user-provided value](1).
   This log entry depends on a [user-provided value](2).
   
   [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5557)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17575][Workflow] Add a check for duplicate task names when saving or updating a workflow. [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS merged PR #17576:
URL: https://github.com/apache/dolphinscheduler/pull/17576


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17575][Workflow] Add a check for duplicate task names when saving or updating a workflow. [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17576:
URL: https://github.com/apache/dolphinscheduler/pull/17576#issuecomment-3400663364

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17576) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [12.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17576&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17576)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17575][Workflow] Add a check for duplicate task names when saving or updating a workflow. [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17576:
URL: https://github.com/apache/dolphinscheduler/pull/17576#issuecomment-3400861434

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17576) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [12.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17576&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17576)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org