apache/dolphinscheduler · error · ServiceException

10158

10158

Error message

workflow definition codes is empty

What it means

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.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:809

        WorkflowDefinition workflowDefinition =
                workflowDefinitionDao.verifyByDefineName(project.getCode(), name.trim());
        if (workflowDefinition == null) {
            return;
        }
        if (workflowDefinitionCode != 0 && workflowDefinitionCode == workflowDefinition.getCode()) {
            return;
        }
        log.warn("workflow definition with the same name {} already exists, workflowDefinitionCode:{}.",
                workflowDefinition.getName(), workflowDefinition.getCode());
        throw new ServiceException(Status.WORKFLOW_DEFINITION_NAME_EXIST, name.trim());
    }

    @Override
    @Transactional
    public void batchDeleteWorkflowDefinitionByCodes(User loginUser, long projectCode, String codes) {
        if (StringUtils.isEmpty(codes)) {
            log.error("Parameter workflowDefinitionCodes is empty, projectCode is {}.", projectCode);
            throw new ServiceException(Status.WORKFLOW_DEFINITION_CODES_IS_EMPTY);
        }

        Set<Long> definitionCodes = Lists.newArrayList(codes.split(Constants.COMMA)).stream().map(Long::parseLong)
                .collect(Collectors.toSet());
        List<WorkflowDefinition> workflowDefinitionList = workflowDefinitionDao.queryByCodes(definitionCodes);
        Set<Long> queryCodes =
                workflowDefinitionList.stream().map(WorkflowDefinition::getCode).collect(Collectors.toSet());
        // definitionCodes - queryCodes
        Set<Long> diffCode =
                definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet());

        if (CollectionUtils.isNotEmpty(diffCode)) {
            log.error("workflow definition does not exist, workflowDefinitionCodes:{}.",
                    diffCode.stream().map(String::valueOf).collect(Collectors.joining(Constants.COMMA)));
            throw new ServiceException(Status.BATCH_DELETE_WORKFLOW_DEFINE_BY_CODES_ERROR,
                    diffCode.stream().map(code -> code + "[workflow definition not exist]")
                            .collect(Collectors.joining(Constants.COMMA)));
        }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check that the selection list is non-empty before calling the batch delete API
  2. Skip the API call entirely when no codes were selected
  3. Validate/split the codes string client-side and return early if empty

Example fix

// before
api.batchDeleteWorkflowDefinitionByCodes(user, projectCode, String.join(",", selectedCodes)); // selectedCodes may be empty
// after
if (!selectedCodes.isEmpty()) {
    api.batchDeleteWorkflowDefinitionByCodes(user, projectCode, String.join(",", selectedCodes));
}
Defensive patterns

Strategy: validation

Validate before calling

if (codes == null || codes.trim().isEmpty()) { return; } // skip empty batch delete

Type guard

boolean hasCodes(String codes) { return codes != null && !codes.trim().isEmpty(); }

Try / catch

try { ... } catch (ServiceException e) { if (e.getCode() == 10158) { /* nothing selected; no-op */ } }

Prevention

When it happens

Trigger: DELETE batch endpoint called with codes="", codes=null, or a whitespace-only string.

Common situations: Frontend sending an empty selection to the batch-delete API, scripts building the codes list from an empty filter result.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/cc39e7ce100741ca. Report an issue: GitHub.