{"record":{"id":"527ec97c08cdc56e","repo":"apache/dolphinscheduler","slug":"data-is-not-valid-527ec9","errorCode":"DATA_IS_NOT_VALID","errorMessage":"Parameter genNum must be great than 1 and less than 100.","messagePattern":"Parameter genNum must be great than 1 and less than 100\\.","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java","lineNumber":318,"sourceCode":"        if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {\n            log.error(\"Task definition does not exist, taskDefinitionCode:{}.\", taskCode);\n            throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode));\n        }\n        List<WorkflowTaskRelation> taskRelationList = workflowTaskRelationDao\n                .queryByCode(projectCode, 0, 0, taskCode);\n        if (CollectionUtils.isNotEmpty(taskRelationList)) {\n            taskRelationList = taskRelationList.stream()\n                    .filter(v -> v.getPreTaskCode() != 0).collect(Collectors.toList());\n        }\n        TaskDefinitionVO taskDefinitionVo = TaskDefinitionVO.fromTaskDefinition(taskDefinition);\n        taskDefinitionVo.setWorkflowTaskRelationList(taskRelationList);\n        return taskDefinitionVo;\n    }\n\n    @Override\n    public List<Long> genTaskCodeList(Integer genNum) {\n        if (genNum == null || genNum < 1 || genNum > 100) {\n            log.warn(\"Parameter genNum must be great than 1 and less than 100.\");\n            throw new ServiceException(Status.DATA_IS_NOT_VALID, genNum);\n        }\n        List<Long> taskCodes = new ArrayList<>();\n        for (int i = 0; i < genNum; i++) {\n            taskCodes.add(CodeGenerateUtils.genCode());\n        }\n        return taskCodes;\n    }\n\n    /**\n     * release task definition\n     *\n     * @param loginUser    login user\n     * @param projectCode  project code\n     * @param code         task definition code\n     * @param releaseState releaseState\n     */\n    @Transactional","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java#L300-L336","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait axios.post('/dolphinscheduler/task-definition/genTaskCodeList', { genNum: 500 })\n// after\nconst genNum = 500\nfor (let i = 0; i < genNum; i += 100) {\n  await axios.post('/dolphinscheduler/task-definition/genTaskCodeList', { genNum: Math.min(100, genNum - i) })\n}","handlingStrategy":"validation","validationCode":"function canGenTaskCodes(genNum: unknown): genNum is number {\n  return typeof genNum === 'number' && Number.isInteger(genNum) && genNum >= 1 && genNum <= 100\n}","typeGuard":"function isValidGenNum(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 100\n}","tryCatchPattern":"try {\n  const codes = await genTaskCodeList(genNum)\n} catch (e) {\n  if (isServiceException(e, 'DATA_IS_NOT_VALID')) {\n    batchQueue.push(...chunk(genNum, 100).map(g => genTaskCodeList(g)))\n  } else throw e\n}","preventionTips":["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."],"tags":["parameter-validation","api","input-validation"],"backgroundTag":"value-out-of-range","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"}