{"record":{"id":"6cedfe9e29eb92e0","repo":"flowable/flowable-engine","slug":"batchsize-has-to-be-larger-than-0-6cedfe","errorCode":null,"errorMessage":"batchSize has to be larger than 0","messagePattern":"batchSize has to be larger than 0","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/delete/DeleteHistoricProcessInstancesUsingBatchesCmd.java","lineNumber":67,"sourceCode":"    protected int batchSize;\n    protected boolean sequential;\n    protected String batchName;\n\n    public DeleteHistoricProcessInstancesUsingBatchesCmd(HistoricProcessInstanceQueryImpl query, int batchSize, String batchName, boolean sequential) {\n        this.historicProcessInstanceQuery = 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 (historicProcessInstanceQuery == 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        ProcessEngineConfigurationImpl engineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        BatchService batchService = engineConfiguration.getBatchServiceConfiguration()\n                .getBatchService();\n\n        long numberOfProcessInstancesToDelete = historicProcessInstanceQuery.count();\n\n        ObjectNode batchConfiguration = engineConfiguration.getObjectMapper().createObjectNode();\n        batchConfiguration.put(\"numberOfInstances\", numberOfProcessInstancesToDelete);\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, historicProcessInstanceQuery);","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/delete/DeleteHistoricProcessInstancesUsingBatchesCmd.java#L49-L85","documentation":"DeleteHistoricProcessInstancesUsingBatchesCmd.execute checks batchSize immediately after the null-query check; if batchSize <= 0 it throws FlowableIllegalArgumentException('batchSize has to be larger than 0'). The batch is split into chunks of batchSize instances, so a non-positive size cannot define valid batch parts.","triggerScenarios":"Constructing DeleteHistoricProcessInstancesUsingBatchesCmd and leaving batchSize at its default/0, or explicitly passing a zero or negative value (DeleteHistoricProcessInstancesUsingBatchesCmd.java:67).","commonSituations":"Default-initialized field never set by the caller; off-by-one or negative computed size (e.g. division of a small total); configuration property resolving to 0.","solutions":["Call setBatchSize with a positive integer (e.g. 100) before executing the command.","Clamp or validate the batchSize value at the call site: Math.max(1, configuredSize).","Check the configuration property feeding batchSize is present and positive."],"exampleFix":"// before\ncmd.setBatchSize(0);\n// after\nif (batchSize <= 0) {\n    batchSize = 100; // or throw a clear config error\n}\ncmd.setBatchSize(batchSize);","handlingStrategy":"validation","validationCode":"if (batchSize <= 0) {\n    throw new IllegalArgumentException(\"batchSize must be > 0, got \" + batchSize);\n}\ncmd.setBatchSize(batchSize);","typeGuard":null,"tryCatchPattern":"try {\n    managementService.executeCommand(cmd);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"batchSize has to be larger than 0\")) {\n        cmd.setBatchSize(DEFAULT_BATCH_SIZE);\n        // retry\n    } else {\n        throw e;\n    }\n}","preventionTips":["Clamp configured batch size with Math.max(1, configured).","Validate external config properties feeding batchSize before command construction."],"tags":["invalid-argument-value","command","validation","flowable"],"backgroundTag":"value-out-of-range","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}