{"record":{"id":"17a5c723e6bf8d93","repo":"flowable/flowable-engine","slug":"there-is-no-batch-with-the-id-configuration","errorCode":null,"errorMessage":"There is no batch with the id ${configuration}","messagePattern":"There is no batch with the id (.+?)","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/ComputeDeleteHistoricCaseInstanceStatusJobHandler.java","lineNumber":57,"sourceCode":"public class ComputeDeleteHistoricCaseInstanceStatusJobHandler implements JobHandler {\n\n    public static final String TYPE = \"compute-delete-historic-case-status\";\n\n    @Override\n    public String getType() {\n        return TYPE;\n    }\n\n    @Override\n    public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {\n        CmmnEngineConfiguration engineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CmmnManagementService managementService = engineConfiguration.getCmmnManagementService();\n        Batch batch = managementService.createBatchQuery()\n                .batchId(configuration)\n                .singleResult();\n\n        if (batch == null) {\n            throw new FlowableIllegalArgumentException(\"There is no batch with the id \" + configuration);\n        }\n\n        if (DeleteCaseInstanceBatchConstants.STATUS_STOPPED.equals(batch.getStatus())) {\n            // The batch has been stopped there is nothing that we need to check anymore, so we will set the repeat to null\n            job.setRepeat(null);\n            return;\n        }\n\n        long totalBatchParts = createStatusQuery(batch, managementService).count();\n        long totalCompleted = createStatusQuery(batch, managementService).completed().count();\n\n        if (totalBatchParts == totalCompleted) {\n            long totalFailed = createStatusQuery(batch, managementService)\n                    .status(DeleteCaseInstanceBatchConstants.STATUS_FAILED)\n                    .count();\n\n            if (totalFailed == 0) {\n                List<BatchPart> deleteBatchParts = managementService.createBatchPartQuery()","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/ComputeDeleteHistoricCaseInstanceStatusJobHandler.java#L39-L75","documentation":"Thrown by ComputeDeleteHistoricCaseInstanceStatusJobHandler.execute() when its periodic status-check job runs but the parent Batch (looked up via createBatchQuery().batchId(configuration)) no longer exists. The job's 'configuration' holds the batch id; without the batch, completion status cannot be computed.","triggerScenarios":"The repeat job fires after the Batch entity was deleted (manually removed, purged by cleanup, or deleted by another management operation), so the query returns null.","commonSituations":"Manual database cleanup deleting ACT_RU_BATCH rows while repeat jobs remain; batch deletion via management API without cancelling its compute-status jobs; environment mismatch (job from a different database).","solutions":["Cancel the repeat job (delete the job entity) when deleting the batch so no orphan status job remains","Restore/verify the batch id in ACT_RU_BATCH matches the job configuration","Check job configuration points to the correct engine/database","Clear stale jobs after data purges"],"exampleFix":"// before\nmanagementService.deleteBatch(batchId); // leaves status job behind\n// after\nmanagementService.deleteBatch(batchId);\nmanagementService.deleteBulkIdJobs / cancel jobs with configuration=batchId; // cancel related jobs too","handlingStrategy":"try-catch","validationCode":"Batch b = managementService.createBatchQuery().batchId(batchId).singleResult();\nif (b == null) { // cancel the orphan repeat job instead of letting it run\n    managementService.deleteJob(jobId); }","typeGuard":null,"tryCatchPattern":"try { jobHandler.execute(job, configuration, scope, ctx); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().contains(\"no batch with the id\")) { log.warn(\"Batch gone; removing orphan status job\", e); managementService.deleteJob(job.getId()); } }","preventionTips":["Cancel repeat/status jobs when deleting a batch","Avoid manual SQL purges of ACT_RU_BATCH without also cleaning jobs","Keep job execution and batch storage in the same environment/database"],"tags":["flowable","cmmn","batch","job","batch-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}