{"record":{"id":"ee0091370741dda1","repo":"flowable/flowable-engine","slug":"batchsize-has-to-be-larger-than-0","errorCode":null,"errorMessage":"batchSize has to be larger than 0","messagePattern":"batchSize has to be larger than 0","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/DeleteHistoricCaseInstancesUsingBatchesCmd.java","lineNumber":68,"sourceCode":"    protected int batchSize;\n    protected boolean sequential;\n    protected String batchName;\n\n    public DeleteHistoricCaseInstancesUsingBatchesCmd(HistoricCaseInstanceQueryImpl query, int batchSize, String batchName, boolean sequential) {\n        this.historicCaseInstanceQuery = query;\n        this.batchSize = batchSize;\n        this.batchName = batchName;\n        this.sequential = sequential;\n    }\n\n    @Override\n    public String execute(CommandContext commandContext) {\n        if (historicCaseInstanceQuery == null) {\n            throw new FlowableIllegalArgumentException(\"query is null\");\n        }\n\n        if (batchSize <= 0) {\n            throw new FlowableIllegalArgumentException(\"batchSize has to be larger than 0\");\n        }\n\n        CmmnEngineConfiguration engineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        BatchService batchService = engineConfiguration.getBatchServiceConfiguration()\n                .getBatchService();\n\n        long numberOfCaseInstancesToDelete = historicCaseInstanceQuery.count();\n\n        ObjectNode batchConfiguration = engineConfiguration.getObjectMapper().createObjectNode();\n        batchConfiguration.put(\"numberOfInstances\", numberOfCaseInstancesToDelete);\n        batchConfiguration.put(\"batchSize\", batchSize);\n        if (sequential) {\n            batchConfiguration.put(\"sequential\", true);\n        }\n\n        ObjectNode queryNode = batchConfiguration.putObject(\"query\");\n\n        populateQueryNode(queryNode, historicCaseInstanceQuery);","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/DeleteHistoricCaseInstancesUsingBatchesCmd.java#L50-L86","documentation":"DeleteHistoricCaseInstancesUsingBatchesCmd deletes historic CMMN case instances in configurable batch sizes. Before executing it validates its inputs, and it requires batchSize strictly greater than 0. The library throws FlowableIllegalArgumentException because a non-positive batch size would make the batch deletion loop impossible or destructive (deleting everything at once).","triggerScenarios":"Calling CmmnHistoryService.createHistoricCaseInstanceQuery()...historic data deletion via a command/batch helper with batchSize <= 0 (0 or negative), typically from a misconfigured cleanup job or a config value read from properties/env that defaulted to 0.","commonSituations":"A batch-size config key absent from configuration so it parses as 0; a user setting batchSize=-1 intending 'unlimited'; code that divides total count to compute batch size when count is 0.","solutions":["Set batchSize to a positive integer, e.g. 100 or 1000, before creating the command","Check any config/property feeding batchSize and give it a sensible default (>0)","Validate batchSize > 0 at your API boundary before invoking the delete command"],"exampleFix":"// before\ncmmnEngineConfiguration.getCommandExecutor().execute(new DeleteHistoricCaseInstancesUsingBatchesCmd(query, 0));\n// after\ncmmnEngineConfiguration.getCommandExecutor().execute(new DeleteHistoricCaseInstancesUsingBatchesCmd(query, 100));","handlingStrategy":"validation","validationCode":"if (batchSize <= 0) throw new IllegalArgumentException(\"batchSize must be > 0, got: \" + batchSize);","typeGuard":null,"tryCatchPattern":"try { cmd.execute(...) } catch (FlowableIllegalArgumentException e) { log.error(\"Bad batch params: {}\", e.getMessage()); }","preventionTips":["Give batch size a positive default in configuration","Validate numeric config values at startup"],"tags":["validation","batch","history-cleanup","illegal-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}