{"record":{"id":"1cd46fb3f40a9c9c","repo":"apache/dolphinscheduler","slug":"50017","errorCode":"50017","errorMessage":"data {0} not valid","messagePattern":"data (.+?) not valid","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java","lineNumber":319,"sourceCode":"            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\n    @Override","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java#L301-L337","documentation":"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.","triggerScenarios":"GET/POST .../task-definition/gen-task-codes with genNum=0, genNum negative, genNum>100, or genNum omitted (null).","commonSituations":"UI sending an empty count field; scripts requesting large batches of codes at once; default-value confusion where an unset parameter arrives as null.","solutions":["Validate the count client-side before calling: ensure it is a non-null integer in 1..100.","If more than 100 codes are needed, call the endpoint repeatedly in chunks of 100 and concatenate.","Catch ServiceException code 50017 and re-prompt for a valid count."],"exampleFix":"// before\nint n = userConfiguredCount; // may be 0 or > 100\nList<Long> codes = service.genTaskCodeList(n); // 50017\n// after\nif (n != null && n >= 1 && n <= 100) {\n    List<Long> codes = service.genTaskCodeList(n);\n} else {\n    throw new IllegalArgumentException(\"genNum must be between 1 and 100\");\n}","handlingStrategy":"validation","validationCode":"if (genNum == null || genNum < 1 || genNum > 100) {\n    throw new IllegalArgumentException(\"genNum must be between 1 and 100\");\n}","typeGuard":"boolean isValidGenNum(Integer genNum) {\n    return genNum != null && genNum >= 1 && genNum <= 100;\n}","tryCatchPattern":"try {\n    return taskDefinitionService.genTaskCodeList(genNum);\n} catch (ServiceException e) {\n    if (e.getCode() == 50017) { /* re-prompt or clamp genNum */ }\n    throw e;\n}","preventionTips":["Clamp or chunk any user-supplied count to 1..100 before calling.","Give UI form fields a sensible default (e.g. 1) to avoid null/0 submissions.","For bulk needs, loop in batches of at most 100."],"tags":["validation","parameter-range","task-codes"],"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-14T05:17:10.506Z"}