{"record":{"id":"e6fddc71b5756be3","repo":"flowable/flowable-engine","slug":"processinstanceid-is-null-e6fddc","errorCode":null,"errorMessage":"processInstanceId is null","messagePattern":"processInstanceId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteProcessInstanceCmd.java","lineNumber":38,"sourceCode":"\n/**\n * @author Joram Barrez\n */\npublic class DeleteProcessInstanceCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String processInstanceId;\n    protected String deleteReason;\n\n    public DeleteProcessInstanceCmd(String processInstanceId, String deleteReason) {\n        this.processInstanceId = processInstanceId;\n        this.deleteReason = deleteReason;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (processInstanceId == null) {\n            throw new ActivitiIllegalArgumentException(\"processInstanceId is null\");\n        }\n\n        commandContext\n                .getExecutionEntityManager()\n                .deleteProcessInstance(processInstanceId, deleteReason);\n        return null;\n    }\n\n}\n","sourceCodeStart":20,"sourceCodeEnd":48,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteProcessInstanceCmd.java#L20-L48","documentation":"DeleteProcessInstanceCmd requires a non-null processInstanceId. When it is null the command throws ActivitiIllegalArgumentException before delegating to ExecutionEntityManager.deleteProcessInstance, since there is no instance to terminate. Fail-fast validation of a mandatory parameter.","triggerScenarios":"Calling RuntimeService.deleteProcessInstance(null, reason), or new DeleteProcessInstanceCmd(null, reason) with an uninitialized id variable.","commonSituations":"Deleting from a flow where the process instance was never started (startProcessInstanceByX returned null); using a result of a query that found nothing; id taken from an unbound variable in a loop.","solutions":["Verify the processInstanceId came from startProcessInstanceX() or a runtimeService.createProcessInstanceQuery() hit","Null-check the id before calling deleteProcessInstance","Fix upstream logic that produced a null id (e.g. .singleResult() returning null)"],"exampleFix":"// before\nruntimeService.deleteProcessInstance(processInstanceId, \"cancelled\");\n// after\nif (processInstanceId != null) {\n    runtimeService.deleteProcessInstance(processInstanceId, \"cancelled\");\n}","handlingStrategy":"validation","validationCode":"if (processInstanceId == null || processInstanceId.isEmpty()) throw new IllegalArgumentException(\"processInstanceId required\");","typeGuard":"boolean validProcessInstanceId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    runtimeService.deleteProcessInstance(processInstanceId, deleteReason);\n} catch (ActivitiIllegalArgumentException e) {\n    log.error(\"Process instance deletion skipped: {}\", e.getMessage());\n}","preventionTips":["Capture the id returned by startProcessInstanceX() and persist it","Handle .singleResult() returning null before using the id","Null-check ids before engine calls in batch/loop deletions"],"tags":["process-instance","null-argument","validation","activiti"],"backgroundTag":"null-argument","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"}