{"record":{"id":"8ddf8b9ac9de034a","repo":"elunez/eladmin","slug":"id","errorCode":null,"errorMessage":"子任务中不能添加当前任务ID","messagePattern":"子任务中不能添加当前任务ID","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java","lineNumber":97,"sourceCode":"    @Transactional(rollbackFor = Exception.class)\n    public void create(QuartzJob resources) {\n        if (!CronExpression.isValidExpression(resources.getCronExpression())){\n            throw new BadRequestException(\"cron表达式格式错误\");\n        }\n        resources = quartzJobRepository.save(resources);\n        quartzManage.addJob(resources);\n    }\n\n    @Override\n    @Transactional(rollbackFor = Exception.class)\n    public void update(QuartzJob resources) {\n        if (!CronExpression.isValidExpression(resources.getCronExpression())){\n            throw new BadRequestException(\"cron表达式格式错误\");\n        }\n        if(StringUtils.isNotBlank(resources.getSubTask())){\n            List<String> tasks = Arrays.asList(resources.getSubTask().split(\"[,，]\"));\n            if (tasks.contains(resources.getId().toString())) {\n                throw new BadRequestException(\"子任务中不能添加当前任务ID\");\n            }\n        }\n        resources = quartzJobRepository.save(resources);\n        quartzManage.updateJobCron(resources);\n    }\n\n    @Override\n    public void updateIsPause(QuartzJob quartzJob) {\n        // 置换暂停状态\n        if (quartzJob.getIsPause()) {\n            quartzManage.resumeJob(quartzJob);\n            quartzJob.setIsPause(false);\n        } else {\n            quartzManage.pauseJob(quartzJob);\n            quartzJob.setIsPause(true);\n        }\n        quartzJobRepository.save(quartzJob);\n    }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/elunez/eladmin/blob/55fbf705956949697dbd68bf9003776609d3d029/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java#L79-L115","documentation":"On job update, if the subTask field (comma-separated list of job IDs to chain after this job) is non-blank, QuartzJobServiceImpl.update splits it on both ',' and the full-width '，' and rejects the request if the resulting list contains the job's own id. Allowing it would make the job re-trigger itself, causing infinite recursive execution.","triggerScenarios":"PUT /api/quartz/jobs with subTask containing the job's own ID, e.g. updating job id=5 with subTask='5,6' or '5，6'. String comparison is used, so both '5' and any exact string match on the ID triggers it.","commonSituations":"Copy-pasting a job's full subTask chain into itself when cloning configurations; UI dropdown listing all jobs including the current one; misunderstanding subTask as a dependency list and adding the parent.","solutions":["Remove the job's own ID from its subTask field; subTask should only contain OTHER job IDs to run after completion.","If chaining behavior on itself is genuinely needed, restructure into two jobs that reference each other's IDs (and re-check whether recursion is intended at all).","Filter the current ID out in the frontend picker before submitting."],"exampleFix":"// before\n{\"id\": \"5\", \"subTask\": \"5,8,9\"} // self-reference -> rejected\n// after\n{\"id\": \"5\", \"subTask\": \"8,9\"}","handlingStrategy":"validation","validationCode":"// strip self-reference before saving\nList<String> ids = Arrays.stream(subTask.split(\"[,，]\"))\n    .map(String::trim).filter(s -> !s.equals(String.valueOf(jobId))).collect(Collectors.toList());\nString safe = String.join(\",\", ids);","typeGuard":"boolean subTaskIsSafe(String subTask, Long selfId) {\n    if (StringUtils.isBlank(subTask)) return true;\n    return Arrays.stream(subTask.split(\"[,，]\"))\n        .map(String::trim)\n        .noneMatch(s -> s.equals(String.valueOf(selfId)));\n}","tryCatchPattern":null,"preventionTips":["Exclude the current job from the subTask picker's options list.","Document in the UI that subTask = jobs to run AFTER this one, dependencies only.","Beware both comma styles (',' and '，') when validating manually."],"tags":["quartz","validation","recursion","config"],"backgroundTag":null,"analyzedSha":"55fbf705956949697dbd68bf9003776609d3d029","analyzedAt":"2026-08-14T11:56:12.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}