{"record":{"id":"0518791471afdbce","repo":"flowable/flowable-engine","slug":"provided-process-instance-id-is-null-051879","errorCode":null,"errorMessage":"Provided process instance id is null","messagePattern":"Provided process instance id is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/EventSubscriptionQueryImpl.java","lineNumber":73,"sourceCode":"    public EventSubscriptionQueryImpl eventName(String eventName) {\r\n        if (eventName == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided event name is null\");\r\n        }\r\n        this.eventName = eventName;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl executionId(String executionId) {\r\n        if (executionId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided execution id is null\");\r\n        }\r\n        this.executionId = executionId;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl processInstanceId(String processInstanceId) {\r\n        if (processInstanceId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided process instance id is null\");\r\n        }\r\n        this.processInstanceId = processInstanceId;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl activityId(String activityId) {\r\n        if (activityId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided activity id is null\");\r\n        }\r\n        this.activityId = activityId;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl eventType(String eventType) {\r\n        if (eventType == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided event type is null\");\r\n        }\r\n        this.eventType = eventType;\r","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/EventSubscriptionQueryImpl.java#L55-L91","documentation":"Thrown by EventSubscriptionQueryImpl.processInstanceId when a null process instance id is supplied as a query criterion. Like the other setters in this query class, it validates the argument eagerly and rejects null so that invalid queries surface immediately at build time with ActivitiIllegalArgumentException. The fix belongs in the calling code that supplies the id.","triggerScenarios":"Calling createEventSubscriptionQuery().processInstanceId(null), typically when the instance id comes from an optional ProcessInstance reference, a variable, or an external request parameter that is missing.","commonSituations":"REST/controller code passing an unset request parameter straight into the query; processInstanceId read from a variable that was never set; code after process end where the instance lookup returns null; copy-paste of query code without binding the actual id.","solutions":["Null-check the process instance id and only add the criterion when present","Ensure the caller actually has a started process instance and passes its getId() value","If filtering by process instance is optional, build the query conditionally","Validate request parameters upstream (controller/validation layer) before reaching the query API"],"exampleFix":"// before\nEventSubscriptionQuery q = runtimeService.createEventSubscriptionQuery().processInstanceId(pid);\n// after\nEventSubscriptionQuery q = runtimeService.createEventSubscriptionQuery();\nif (pid != null) {\n    q = q.processInstanceId(pid);\n}","handlingStrategy":"validation","validationCode":"if (processInstanceId == null) { throw new IllegalArgumentException(\"processInstanceId must be non-null before querying\"); }\nquery.processInstanceId(processInstanceId);","typeGuard":"boolean hasInstanceId(ProcessInstance pi) { return pi != null && pi.getId() != null; }","tryCatchPattern":"try {\n    query.processInstanceId(pid);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    // pid was null: ensure the process instance exists and was passed\n}","preventionTips":["Validate request parameters at the API boundary before building queries","Confirm the process instance is started and not yet removed before querying by its id","Conditionally apply the criterion when instance filtering is optional"],"tags":["java","activiti","query","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-18T11:17:12.947Z"}