apache/dolphinscheduler · error · ServiceException
DATA_IS_NOT_VALID
DATA_IS_NOT_VALID
Error message
Parameter genNum must be great than 1 and less than 100.
What it means
genTaskCodeList generates batch task definition codes but first validates the requested count. If genNum is null, less than 1, or greater than 100, it throws a ServiceException with Status.DATA_IS_NOT_VALID and echoes the offending genNum. This caps batch size to protect the code-generation loop and downstream storage.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java:318
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
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
*/
@TransactionalView on GitHub (pinned to 02eac45a1b)
Solutions
- Set genNum to an integer between 1 and 100 inclusive before calling.
- If more than 100 codes are needed, call the endpoint multiple times in batches of <=100.
- Default missing/empty form input to 1 (or the intended count) instead of sending 0/empty.
- Ensure the client sends the parameter as a numeric value so it binds to Integer without becoming null.
Example fix
// before
await axios.post('/dolphinscheduler/task-definition/genTaskCodeList', { genNum: 500 })
// after
const genNum = 500
for (let i = 0; i < genNum; i += 100) {
await axios.post('/dolphinscheduler/task-definition/genTaskCodeList', { genNum: Math.min(100, genNum - i) })
} Defensive patterns
Strategy: validation
Validate before calling
function canGenTaskCodes(genNum: unknown): genNum is number {
return typeof genNum === 'number' && Number.isInteger(genNum) && genNum >= 1 && genNum <= 100
} Type guard
function isValidGenNum(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 100
} Try / catch
try {
const codes = await genTaskCodeList(genNum)
} catch (e) {
if (isServiceException(e, 'DATA_IS_NOT_VALID')) {
batchQueue.push(...chunk(genNum, 100).map(g => genTaskCodeList(g)))
} else throw e
} Prevention
- Always clamp batch sizes to 1..100 at the call site before invoking.
- Chunk large requests into batches of 100 via a helper.
- Never send the field as a free-text input; use a number input with min=1 max=100.
When it happens
Trigger: Calling the task-definition code-generation API endpoint (taskDefinition/genTaskCodeList) with genNum=0, genNum negative, genNum>100, or omitting genNum entirely so it binds to null.
Common situations: Frontend batch-import forms defaulting to 0 or an empty field; scripts looping 'generate all codes' with a huge count; API consumers passing the parameter as a string that fails Integer binding; pagination-less bulk tooling requesting thousands of codes at once.
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
- REQUEST_PARAMS_NOT_VALID_ERROR
- DESCRIPTION_TOO_LONG_ERROR
- NAME_NULL
- TASK_GROUP_SIZE_ERROR
- USER_NO_OPERATION_PERM
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/527ec97c08cdc56e.
Report an issue: GitHub.