{"record":{"id":"ba9f73f8fc553a74","repo":"flowable/flowable-engine","slug":"there-are-no-case-instance-ids-to-delete","errorCode":null,"errorMessage":"There are no case instance ids to delete","messagePattern":"There are no case instance ids to delete","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/DeleteHistoricCaseInstanceIdsJobHandler.java","lineNumber":86,"sourceCode":"\n        CmmnManagementService managementService = engineConfiguration.getCmmnManagementService();\n\n        BatchPart computeBatchPart = managementService.createBatchPartQuery()\n                .id(batchPart.getSearchKey())\n                .singleResult();\n\n        JsonNode computeBatchPartResult = getBatchPartResult(computeBatchPart, engineConfiguration);\n        JsonNode idsToDelete = computeBatchPartResult.path(\"caseInstanceIdsToDelete\");\n        Set<String> caseInstanceIdsToDelete = new HashSet<>();\n\n        if (idsToDelete.isArray()) {\n            for (JsonNode idNode : idsToDelete) {\n                caseInstanceIdsToDelete.add(idNode.stringValue());\n            }\n        }\n\n        if (caseInstanceIdsToDelete.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"There are no case instance ids to delete\");\n        }\n        \n        String status = DeleteCaseInstanceBatchConstants.STATUS_COMPLETED;\n        ObjectNode resultNode = engineConfiguration.getObjectMapper().createObjectNode();\n\n        CmmnHistoryService historyService = engineConfiguration.getCmmnHistoryService();\n        \n        try {\n            historyService.bulkDeleteHistoricCaseInstances(caseInstanceIdsToDelete);\n            resultNode.withArray(\"caseInstanceIdsDeleted\")\n                .addAll((ArrayNode) idsToDelete);\n            \n        } catch (FlowableException ex) {\n            status = DeleteCaseInstanceBatchConstants.STATUS_FAILED;\n            resultNode.withArray(\"caseInstanceIdsFailedToDelete\")\n                    .addObject()\n                    .put(\"id\", caseInstanceIdsToDelete.iterator().next())\n                    .put(\"error\", ex.getMessage())","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/DeleteHistoricCaseInstanceIdsJobHandler.java#L68-L104","documentation":"Thrown by DeleteHistoricCaseInstanceIdsJobHandler.execute() when the ids-to-delete list parsed from the batch part configuration is empty. An empty deletion batch is treated as invalid because there is nothing to do and the batch completion logic expects at least one id.","triggerScenarios":"The batch part's configuration JSON has an empty or missing 'idsToDelete' array, so after parsing, caseInstanceIdsToDelete.isEmpty() is true.","commonSituations":"Creating a delete batch with a query that matched zero case instances; corrupted or truncated batch configuration JSON; a bug where ids were consumed/removed before the job ran.","solutions":["Ensure the HistoricCaseInstanceQuery used to build the batch matches at least one case instance before creating the batch","Check the batch configuration JSON contains a non-empty idsToDelete array","Validate case ids exist in history (case instances were finished/archived) before batching","Do not create a batch when the query count is 0; handle the no-op case in caller code"],"exampleFix":"// before\nmanagementService.bulkDeleteHistoricCaseInstances(query, 10, true); // query matched 0\n// after\nif (query.count() > 0) {\n    managementService.bulkDeleteHistoricCaseInstances(query, 10, true);\n}","handlingStrategy":"validation","validationCode":"long count = historicCaseInstanceQuery.count();\nif (count == 0) throw new IllegalArgumentException(\"Query matches no case instances; nothing to delete\");\nmanagementService.bulkDeleteHistoricCaseInstances(historicCaseInstanceQuery, batchSize, sequential);","typeGuard":null,"tryCatchPattern":"try { createBatch(cmd); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().contains(\"no case instance ids to delete\")) { log.warn(\"Empty delete batch skipped\"); return null; } throw e; }","preventionTips":["Check query.count() > 0 before creating a delete batch","Do not hand-edit idsToDelete in batch configuration JSON","Confirm historic case instances exist (finished cases) before batching"],"tags":["flowable","cmmn","batch","empty-list","validation"],"backgroundTag":"empty-required-field","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"}