{"record":{"id":"b2e223fabef759e1","repo":"flowable/flowable-engine","slug":"processinstanceids-is-null","errorCode":null,"errorMessage":"processInstanceIds is null","messagePattern":"processInstanceIds is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/BulkDeleteHistoricProcessInstancesCmd.java","lineNumber":36,"sourceCode":"\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.engine.impl.util.CommandContextUtil;\n\npublic class BulkDeleteHistoricProcessInstancesCmd implements Command<Object>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected Collection<String> processInstanceIds;\n\n    public BulkDeleteHistoricProcessInstancesCmd(Collection<String> processInstanceIds) {\n        this.processInstanceIds = processInstanceIds;\n    }\n\n    @Override\n    public Object execute(CommandContext commandContext) {\n        if (processInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"processInstanceIds is null\");\n        }\n\n        if (processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"processInstanceIds is empty\");\n        }\n        \n        CommandContextUtil.getHistoryManager(commandContext).recordBulkDeleteProcessInstances(processInstanceIds);\n\n        return null;\n    }\n\n}\n","sourceCodeStart":18,"sourceCodeEnd":49,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/BulkDeleteHistoricProcessInstancesCmd.java#L18-L49","documentation":"BulkDeleteHistoricProcessInstancesCmd.execute throws FlowableIllegalArgumentException when the collection of process instance ids passed to bulk-delete historic process instances is null. The bulk delete is a single history-recording operation, so it cannot proceed without an explicit id list.","triggerScenarios":"Calling runtimeService/historyService bulk delete historic process instances API (e.g. managementService or custom code constructing new BulkDeleteHistoricProcessInstancesCmd(null)) with a null List, commonly the result of an earlier query that returned null or an unset method parameter.","commonSituations":"Code paths where the id list comes from another query or a nullable variable and was never null-checked; Spring beans with optional parameters; refactors where a default empty list was replaced by null.","solutions":["Null-check the id collection before invoking the bulk delete and fail fast in your own code with a clear message.","Ensure upstream queries return empty lists instead of null (initialize the list at declaration).","If ids come from configuration/input, validate presence before calling the API.","Wrap the call in try-catch for FlowableIllegalArgumentException only as a last-resort guard, not as control flow."],"exampleFix":"// before\nhistoryService.bulkDeleteHistoricProcessInstances(ids); // ids may be null\n// after\nif (ids == null) {\n    throw new IllegalArgumentException(\"processInstanceIds must not be null\");\n}\nhistoryService.bulkDeleteHistoricProcessInstances(ids);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(processInstanceIds, \"processInstanceIds must not be null\");","typeGuard":"boolean isUsableIdList(List<String> ids) {\n    return ids != null && !ids.isEmpty();\n}","tryCatchPattern":"try {\n    historyService.bulkDeleteHistoricProcessInstances(ids);\n} catch (FlowableIllegalArgumentException e) {\n    logger.error(\"Invalid argument for bulk historic delete: {}\", e.getMessage());\n}","preventionTips":["Initialize collections at declaration instead of leaving them null.","Null-check parameters at API boundaries in your own service layer.","Prefer returning empty lists over null from helper queries.","Use Objects.requireNonNull early to fail fast with a clear message."],"tags":["flowable","history","null-argument","bulk-delete","validation"],"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"}