{"record":{"id":"d2bdf82b597aae34","repo":"apache/dolphinscheduler","slug":"copy-workflow-definition-error","errorCode":"COPY_WORKFLOW_DEFINITION_ERROR","errorMessage":"COPY_WORKFLOW_DEFINITION_ERROR: copy workflow definition from project {0} to project {1} error, failed workflows: {2}","messagePattern":"COPY_WORKFLOW_DEFINITION_ERROR: copy workflow definition from project (.+?) to project (.+?) error, failed workflows: (.+?)","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":1672,"sourceCode":"\n    /**\n     * check batch operate result\n     *\n     * @param srcProjectCode    srcProjectCode\n     * @param targetProjectCode targetProjectCode\n     * @param result            result\n     * @param failedWorkflowList failedWorkflowList\n     * @param isCopy            isCopy\n     */\n    private void checkBatchOperateResult(long srcProjectCode, long targetProjectCode,\n                                         List<String> failedWorkflowList, boolean isCopy) {\n        if (!failedWorkflowList.isEmpty()) {\n            String failedWorkflow = String.join(\",\", failedWorkflowList);\n            if (isCopy) {\n                log.error(\n                        \"Copy workflow definition error, srcProjectCode:{}, targetProjectCode:{}, failedWorkflowList:{}.\",\n                        srcProjectCode, targetProjectCode, failedWorkflow);\n                throw new ServiceException(Status.COPY_WORKFLOW_DEFINITION_ERROR, srcProjectCode, targetProjectCode,\n                        failedWorkflow);\n            }\n            log.error(\n                    \"Move workflow definition error, srcProjectCode:{}, targetProjectCode:{}, failedWorkflowList:{}.\",\n                    srcProjectCode, targetProjectCode, failedWorkflow);\n            throw new ServiceException(Status.MOVE_WORKFLOW_DEFINITION_ERROR, srcProjectCode, targetProjectCode,\n                    failedWorkflow);\n        }\n        log.info(\"Batch {} workflow definition complete, srcProjectCode:{}, targetProjectCode:{}.\",\n                isCopy ? \"copy\" : \"move\", srcProjectCode, targetProjectCode);\n    }\n\n    /**\n     * query the pagination versions info by one certain workflow definition code\n     *\n     * @param loginUser   login user info to check auth\n     * @param projectCode project code\n     * @param pageNo      page number","sourceCodeStart":1654,"sourceCodeEnd":1690,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L1654-L1690","documentation":"Thrown by checkBatchOperateResult at the end of a batch COPY of workflow definitions when at least one workflow failed to copy. failedWorkflowList collects per-workflow failures (e.g. from createDagDefine errors or task params parse failures), and this error reports the source project, target project, and the comma-separated 'code[name]' list of failed workflows. The batch is best-effort: other workflows may have been copied.","triggerScenarios":"Calling the copy-workflows endpoint (isCopy=true) where any workflow failed during the inner copy loop — e.g. DAG creation exceptions (invalid task relations, unmapped task codes), invalid Switch/Condition taskParams, or schedule/DB write failures.","commonSituations":"Copying workflows whose task params are corrupt or from a different version; target project permission/schema problems; name collisions or dangling task codes in the source DAG; copying many workflows where one bad definition aborts the aggregate result.","solutions":["Read the failed workflows list in the message and retry copying only those workflows after fixing each cause.","Inspect API server logs for the per-workflow exception logged during the copy loop (e.g. 'Copy workflow definition error, workflowDefinitionCode from ... to ...').","Fix invalid task definitions (Switch/Condition taskParams, missing task codes) in the source workflow, then re-run the copy.","Verify you have write permission on the target project and that its metadata rows are healthy before re-copying."],"exampleFix":"// before: batch copy includes a corrupt workflow -> whole call errors\nPOST /projects/{code}/workflow-definition/copy  codes=111,222(bad),333\n// after: exclude known-bad codes, fix 222, copy separately\ncodes=111,333  ->  success; then repair wf 222's Switch taskParams and copy it alone","handlingStrategy":"validation","validationCode":"// Validate each source workflow's task params before batch copy\nboolean allTasksValid(WorkflowDefinition wf) {\n  return taskDefinitionMapper.queryByWorkflowDefinitionCode(wf.getCode()).stream()\n      .allMatch(t -> t.getTaskParams() != null && !t.getTaskParams().trim().isEmpty());\n}","typeGuard":null,"tryCatchPattern":"try {\n    workflowDefinitionService.batchCopyWorkflowDefinition(user, srcProjectCode, targetProjectCode, codes, true);\n} catch (ServiceException e) {\n    // message lists failed \"code[name]\" workflows; fix those and re-copy individually\n}","preventionTips":["Validate task_params of all tasks in the source workflows before batch copying.","Copy workflows in small batches so one bad definition doesn't fail a large aggregate.","Check the API server logs for the per-workflow 'Copy workflow definition error' entries.","Ensure the target project exists and you hold write permission on it."],"tags":["copy-workflow","batch-operation","partial-failure","rest-api"],"backgroundTag":"batch-operation-partial-failure","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}