{"record":{"id":"58b4e5191c587aae","repo":"flowable/flowable-engine","slug":"process-instance-id-is-null","errorCode":null,"errorMessage":"Process instance id is null","messagePattern":"Process instance id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ExecutionQueryImpl.java","lineNumber":299,"sourceCode":"    }\n\n    @Override\n    public ExecutionQuery processDefinitionEngineVersion(String processDefinitionEngineVersion) {\n        if (processDefinitionEngineVersion == null) {\n            throw new FlowableIllegalArgumentException(\"Process definition engine version is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionEngineVersion = processDefinitionEngineVersion;\n        } else {\n            this.processDefinitionEngineVersion = processDefinitionEngineVersion;\n        }\n        return this;\n    }\n\n    @Override\n    public ExecutionQueryImpl processInstanceId(String processInstanceId) {\n        if (processInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"Process instance id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.processInstanceId = processInstanceId;\n        } else {\n            this.processInstanceId = processInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public ExecutionQuery processInstanceIds(Set<String> processInstanceIds) {\n        if (processInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"Set of process instance ids is null\");\n        }\n        if (processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of process instance ids is empty\");\n        }\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ExecutionQueryImpl.java#L281-L317","documentation":"Flowable's ExecutionQueryImpl.processInstanceId() validates its argument and throws FlowableIllegalArgumentException when the process instance id is null. The query API requires a concrete, non-null id to build the WHERE clause; a null would produce an invalid or unbounded query. The library fails fast at query-construction time rather than returning wrong or empty results.","triggerScenarios":"Calling runtimeService.createExecutionQuery().processInstanceId(null), typically when the id variable comes from an upstream lookup, a request parameter, or a method parameter that was never initialized.","commonSituations":"Passing a result of processInstance.getId() from a lookup that returned null (instance already completed/removed); wiring a REST path variable that is absent; refactoring where a variable was renamed but not assigned before the query.","solutions":["Check the variable holding the id for null before building the query and return early or substitute a safe default","Trace where the id originates (e.g. execution/process instance lookup) and handle the not-found case instead of passing null through","If you intend to query by something else, use the appropriate filter (processInstanceBusinessKey, processDefinitionKey) instead of an id","Wrap the query building in try-catch for FlowableIllegalArgumentException if null inputs are legitimately possible"],"exampleFix":"// before\nExecutionQuery query = runtimeService.createExecutionQuery().processInstanceId(instanceId);\n// after\nif (instanceId == null) {\n    throw new IllegalStateException(\"processInstanceId must be provided\");\n}\nExecutionQuery query = runtimeService.createExecutionQuery().processInstanceId(instanceId);","handlingStrategy":"validation","validationCode":"if (instanceId == null) {\n    throw new IllegalArgumentException(\"instanceId must not be null before querying executions\");\n}","typeGuard":"boolean hasProcessInstanceId(String id) {\n    return id != null && !id.isBlank();\n}","tryCatchPattern":"try {\n    Execution exec = runtimeService.createExecutionQuery().processInstanceId(id).singleResult();\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid execution query: {}\", e.getMessage());\n}","preventionTips":["Null-check query parameters before building Flowable queries","Handle 'instance not found' at the source lookup instead of passing null downstream","Use Objects.requireNonNull with a descriptive message at API boundaries"],"tags":["flowable","null-check","query","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"}