apache/dolphinscheduler · warning · ServiceException

50017

50017

Error message

data {0} not valid

What it means

Thrown when the requested number of task codes to generate is null or outside the allowed range 1..100. genTaskCodeList bulk-generates unique task codes via CodeGenerateUtils and validates genNum up front to bound the loop.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java:319

            log.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode);
            throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode));
        }
        List<WorkflowTaskRelation> taskRelationList = workflowTaskRelationDao
                .queryByCode(projectCode, 0, 0, taskCode);
        if (CollectionUtils.isNotEmpty(taskRelationList)) {
            taskRelationList = taskRelationList.stream()
                    .filter(v -> v.getPreTaskCode() != 0).collect(Collectors.toList());
        }
        TaskDefinitionVO taskDefinitionVo = TaskDefinitionVO.fromTaskDefinition(taskDefinition);
        taskDefinitionVo.setWorkflowTaskRelationList(taskRelationList);
        return taskDefinitionVo;
    }

    @Override
    public List<Long> genTaskCodeList(Integer genNum) {
        if (genNum == null || genNum < 1 || genNum > 100) {
            log.warn("Parameter genNum must be great than 1 and less than 100.");
            throw new ServiceException(Status.DATA_IS_NOT_VALID, genNum);
        }
        List<Long> taskCodes = new ArrayList<>();
        for (int i = 0; i < genNum; i++) {
            taskCodes.add(CodeGenerateUtils.genCode());
        }
        return taskCodes;
    }

    /**
     * release task definition
     *
     * @param loginUser    login user
     * @param projectCode  project code
     * @param code         task definition code
     * @param releaseState releaseState
     */
    @Transactional
    @Override

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Validate the count client-side before calling: ensure it is a non-null integer in 1..100.
  2. If more than 100 codes are needed, call the endpoint repeatedly in chunks of 100 and concatenate.
  3. Catch ServiceException code 50017 and re-prompt for a valid count.

Example fix

// before
int n = userConfiguredCount; // may be 0 or > 100
List<Long> codes = service.genTaskCodeList(n); // 50017
// after
if (n != null && n >= 1 && n <= 100) {
    List<Long> codes = service.genTaskCodeList(n);
} else {
    throw new IllegalArgumentException("genNum must be between 1 and 100");
}
Defensive patterns

Strategy: validation

Validate before calling

if (genNum == null || genNum < 1 || genNum > 100) {
    throw new IllegalArgumentException("genNum must be between 1 and 100");
}

Type guard

boolean isValidGenNum(Integer genNum) {
    return genNum != null && genNum >= 1 && genNum <= 100;
}

Try / catch

try {
    return taskDefinitionService.genTaskCodeList(genNum);
} catch (ServiceException e) {
    if (e.getCode() == 50017) { /* re-prompt or clamp genNum */ }
    throw e;
}

Prevention

When it happens

Trigger: GET/POST .../task-definition/gen-task-codes with genNum=0, genNum negative, genNum>100, or genNum omitted (null).

Common situations: UI sending an empty count field; scripts requesting large batches of codes at once; default-value confusion where an unset parameter arrives as null.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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