{"record":{"id":"cc39e7ce100741ca","repo":"apache/dolphinscheduler","slug":"10158","errorCode":"10158","errorMessage":"workflow definition codes is empty","messagePattern":"workflow definition codes is empty","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":809,"sourceCode":"        WorkflowDefinition workflowDefinition =\n                workflowDefinitionDao.verifyByDefineName(project.getCode(), name.trim());\n        if (workflowDefinition == null) {\n            return;\n        }\n        if (workflowDefinitionCode != 0 && workflowDefinitionCode == workflowDefinition.getCode()) {\n            return;\n        }\n        log.warn(\"workflow definition with the same name {} already exists, workflowDefinitionCode:{}.\",\n                workflowDefinition.getName(), workflowDefinition.getCode());\n        throw new ServiceException(Status.WORKFLOW_DEFINITION_NAME_EXIST, name.trim());\n    }\n\n    @Override\n    @Transactional\n    public void batchDeleteWorkflowDefinitionByCodes(User loginUser, long projectCode, String codes) {\n        if (StringUtils.isEmpty(codes)) {\n            log.error(\"Parameter workflowDefinitionCodes is empty, projectCode is {}.\", projectCode);\n            throw new ServiceException(Status.WORKFLOW_DEFINITION_CODES_IS_EMPTY);\n        }\n\n        Set<Long> definitionCodes = Lists.newArrayList(codes.split(Constants.COMMA)).stream().map(Long::parseLong)\n                .collect(Collectors.toSet());\n        List<WorkflowDefinition> workflowDefinitionList = workflowDefinitionDao.queryByCodes(definitionCodes);\n        Set<Long> queryCodes =\n                workflowDefinitionList.stream().map(WorkflowDefinition::getCode).collect(Collectors.toSet());\n        // definitionCodes - queryCodes\n        Set<Long> diffCode =\n                definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet());\n\n        if (CollectionUtils.isNotEmpty(diffCode)) {\n            log.error(\"workflow definition does not exist, workflowDefinitionCodes:{}.\",\n                    diffCode.stream().map(String::valueOf).collect(Collectors.joining(Constants.COMMA)));\n            throw new ServiceException(Status.BATCH_DELETE_WORKFLOW_DEFINE_BY_CODES_ERROR,\n                    diffCode.stream().map(code -> code + \"[workflow definition not exist]\")\n                            .collect(Collectors.joining(Constants.COMMA)));\n        }","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L791-L827","documentation":"Thrown in WorkflowDefinitionServiceImpl.batchDeleteWorkflowDefinitionByCodes when the codes parameter is null/empty: the batch-delete endpoint received no workflow definition codes to operate on, so it fails fast instead of performing an empty batch.","triggerScenarios":"DELETE batch endpoint called with codes=\"\", codes=null, or a whitespace-only string.","commonSituations":"Frontend sending an empty selection to the batch-delete API, scripts building the codes list from an empty filter result.","solutions":["Check that the selection list is non-empty before calling the batch delete API","Skip the API call entirely when no codes were selected","Validate/split the codes string client-side and return early if empty"],"exampleFix":"// before\napi.batchDeleteWorkflowDefinitionByCodes(user, projectCode, String.join(\",\", selectedCodes)); // selectedCodes may be empty\n// after\nif (!selectedCodes.isEmpty()) {\n    api.batchDeleteWorkflowDefinitionByCodes(user, projectCode, String.join(\",\", selectedCodes));\n}","handlingStrategy":"validation","validationCode":"if (codes == null || codes.trim().isEmpty()) { return; } // skip empty batch delete","typeGuard":"boolean hasCodes(String codes) { return codes != null && !codes.trim().isEmpty(); }","tryCatchPattern":"try { ... } catch (ServiceException e) { if (e.getCode() == 10158) { /* nothing selected; no-op */ } }","preventionTips":["Guard batch endpoints with non-empty checks client-side","Never send empty/whitespace codes strings","No-op early when selection is empty"],"tags":["batch-delete","empty-argument","workflow"],"backgroundTag":"empty-required-field","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"}