{"record":{"id":"7566674b75149a65","repo":"flowable/flowable-engine","slug":"processinstanceid-is-null-756667","errorCode":null,"errorMessage":"processInstanceId is null","messagePattern":"processInstanceId is null","errorType":"validation","errorClass":"org.flowable.common.engine.api.FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java","lineNumber":83,"sourceCode":"        super(commandContext);\n        this.variableServiceConfiguration = variableServiceConfiguration;\n    }\n\n    public HistoricVariableInstanceQueryImpl(CommandExecutor commandExecutor, VariableServiceConfiguration variableServiceConfiguration) {\n        super(commandExecutor);\n        this.variableServiceConfiguration = variableServiceConfiguration;\n    }\n\n    @Override\n    public HistoricVariableInstanceQuery id(String id) {\n        this.id = id;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQueryImpl processInstanceId(String processInstanceId) {\n        if (processInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"processInstanceId is null\");\n        }\n        this.processInstanceId = processInstanceId;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQuery processInstanceIds(Collection<String> processInstanceIds) {\n        if (processInstanceIds == null || processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"processInstanceIds is empty\");\n        }\n        this.processInstanceIds = processInstanceIds;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQueryImpl executionId(String executionId) {\n        if (executionId == null) {\n            throw new FlowableIllegalArgumentException(\"Execution id is null\");","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java#L65-L101","documentation":"HistoricVariableInstanceQueryImpl.processInstanceId requires a non-null process instance id and throws FlowableIllegalArgumentException when null is passed. The query builder fails fast so an invalid query never reaches the database. Supplying null would otherwise produce ambiguous or full-table results.","triggerScenarios":"Calling createHistoricVariableInstanceQuery().processInstanceId(null), often when the id comes from a nullable variable, an optional execution, or a failed processInstance lookup.","commonSituations":"Passing the result of an API that returned null (e.g. DelegateExecution.getProcessInstanceId() in odd contexts); chaining queries built from optional request parameters; unit tests with uninitialized ids.","solutions":["Only call processInstanceId when the id is non-null; omit the clause otherwise","Resolve the id correctly before building the query (check the execution/context)","Validate the id with Objects.requireNonNull or an if-check before the call","If querying across instances, drop the processInstanceId constraint instead of passing null"],"exampleFix":"// before\nquery.processInstanceId(execution.getProcessInstanceId());\n// after\nString pid = execution.getProcessInstanceId();\nif (pid != null) { query.processInstanceId(pid); }","handlingStrategy":"validation","validationCode":"if (processInstanceId == null || processInstanceId.isBlank()) {\n    return; // skip clause instead of calling the API\n}\nquery.processInstanceId(processInstanceId);","typeGuard":"static boolean hasProcessInstanceId(String pid) {\n    return pid != null && !pid.isBlank();\n}","tryCatchPattern":"try {\n    query.processInstanceId(pid);\n} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {\n    // log and query without the clause, or rethrow with context\n}","preventionTips":["Null-check ids sourced from optional contexts before building queries","Prefer Objects.requireNonNull at call sites with expected ids","Distinguish 'no filter' from 'null filter' explicitly","Cover query builders with null-input unit tests"],"tags":["flowable","query","null","history"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T16:30:33.424Z"}