Skip to content

Conversation

@njnu-seafish
Copy link
Contributor

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

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

@SbloodyS SbloodyS added this to the 3.3.2 milestone Oct 14, 2025
@SbloodyS SbloodyS added priority:high bug Something isn't working labels Oct 14, 2025
@njnu-seafish
Copy link
Contributor Author

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.(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()
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()
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

if (!taskNameSet.add(taskDefinitionLog.getName())) {
log.error(
"Generate task definition list failed, the given task definition name is duplicate, taskName: {}, taskDefinition: {}",
taskDefinitionLog.getName(), taskDefinitionLog);

Check failure

Code scanning / CodeQL

Log Injection High

This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
12.5% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

Copy link
Member

@ruanwenjun ruanwenjun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@SbloodyS SbloodyS merged commit b3a40d8 into apache:dev Oct 15, 2025
77 of 84 checks passed
davidzollo pushed a commit to davidzollo/dolphinscheduler that referenced this pull request Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working priority:high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [Workflow] Duplicate task names within the same workflow can be saved, but the workflow cannot be executed.

3 participants