{"record":{"id":"105a360c3faa405c","repo":"flowable/flowable-engine","slug":"caseinstanceids-are-null","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/BulkDeleteCaseInstancesCmd.java","lineNumber":37,"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 BulkDeleteCaseInstancesCmd implements Command<Void> {\n\n    protected Collection<String> caseInstanceIds;\n\n    public BulkDeleteCaseInstancesCmd(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        for (String instanceId : instanceIdSet) {\n            DeleteCaseInstanceCmd command = new DeleteCaseInstanceCmd(instanceId);\n            command.execute(commandContext);\n        }\n        return null;\n    }\n}\n","sourceCodeStart":19,"sourceCodeEnd":47,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/BulkDeleteCaseInstancesCmd.java#L19-L47","documentation":"BulkDeleteCaseInstancesCmd.execute throws FlowableIllegalArgumentException when the caseInstanceIds collection is null. Bulk commands delegate to DeleteCaseInstanceCmd per id, so a null collection cannot be iterated; the command fails fast with a clear message.","triggerScenarios":"Calling cmmnRuntimeService.bulkDeleteCaseInstances(null) or constructing BulkDeleteCaseInstancesCmd with a null collection — e.g. an upstream query that returned null instead of an empty list.","commonSituations":"A repository/service method returning null when no ids matched; deserialization of an empty request body into a null field; unguarded variable passing.","solutions":["Pass a non-null collection (an empty list is fine) to bulkDeleteCaseInstances","Coalesce null to Collections.emptyList() at the call site","Guard the call: only invoke bulk delete when the id list was actually populated"],"exampleFix":"// before\ncmmnRuntimeService.bulkDeleteCaseInstances(ids); // ids may be null\n// after\ncmmnRuntimeService.bulkDeleteCaseInstances(ids == null ? Collections.emptyList() : ids);","handlingStrategy":"type-guard","validationCode":"if (caseInstanceIds == null) caseInstanceIds = Collections.emptyList();","typeGuard":"boolean isNonNullCollection(Collection<?> c) { return c != null; }","tryCatchPattern":"try {\n    cmmnRuntimeService.bulkDeleteCaseInstances(ids);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Bulk delete rejected: {}\", e.getMessage());\n}","preventionTips":["Never return null collections from your id-gathering methods — return empty lists","Coalesce nulls at API boundaries","Enable static analysis nullness checks (e.g. NullAway)"],"tags":["flowable","cmmn","bulk-delete","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"}