{"record":{"id":"b163965395232402","repo":"flowable/flowable-engine","slug":"caseinstanceids-are-null-b16396","errorCode":null,"errorMessage":"caseInstanceIds are null","messagePattern":"caseInstanceIds are null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/BulkTerminateCaseInstancesCmd.java","lineNumber":38,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\n\n/**\n * @author Christopher Welsch\n */\npublic class BulkTerminateCaseInstancesCmd implements Command<Void> {\n\n    protected Collection<String> caseInstanceIds;\n\n    public BulkTerminateCaseInstancesCmd(Collection<String> caseInstanceIds) {\n        this.caseInstanceIds = caseInstanceIds;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (caseInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceIds are null\");\n        }\n        Set<String> instanceIdSet = new HashSet<>(caseInstanceIds);\n\n        for (String instanceId : instanceIdSet) {\n            CommandContextUtil.getAgenda(commandContext).planManualTerminateCaseInstanceOperation(instanceId);\n        }\n        return null;\n    }\n}\n","sourceCodeStart":20,"sourceCodeEnd":48,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/BulkTerminateCaseInstancesCmd.java#L20-L48","documentation":"BulkTerminateCaseInstancesCmd.execute throws FlowableIllegalArgumentException when the caseInstanceIds collection is null. The command builds a deduplicated Set of ids and plans a manual terminate operation per id on the agenda; a null collection is rejected before planning begins.","triggerScenarios":"Calling cmmnRuntimeService.bulkTerminateCaseInstances(null) or constructing the command with a null id collection, e.g. from an upstream batch job whose id query returned null.","commonSituations":"Termination workflows driven by external events where the event payload lacks the ids field; unguarded method chaining producing null; reuse of a variable cleared earlier in the flow.","solutions":["Pass a non-null collection of case instance ids to bulkTerminateCaseInstances","Coalesce null to an empty list at the call site","Validate the id list before scheduling termination operations"],"exampleFix":"// before\nruntimeService.bulkTerminateCaseInstances(idsToTerminate);\n// after\nruntimeService.bulkTerminateCaseInstances(idsToTerminate == null ? Collections.emptyList() : idsToTerminate);","handlingStrategy":"type-guard","validationCode":"if (idsToTerminate == null) idsToTerminate = Collections.emptyList();","typeGuard":"boolean isNonNullCollection(Collection<?> c) { return c != null; }","tryCatchPattern":"try {\n    cmmnRuntimeService.bulkTerminateCaseInstances(ids);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Bulk terminate rejected: {}\", e.getMessage());\n}","preventionTips":["Validate event payloads contain the ids field before scheduling termination","Never pass through variables that may be null; normalize at boundaries","Add nullness annotations/lint checks on service-layer inputs"],"tags":["flowable","cmmn","terminate","null-check"],"backgroundTag":"null-argument","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"}