{"record":{"id":"679010c95ea16fbe","repo":"flowable/flowable-engine","slug":"taskid-is-null-679010","errorCode":null,"errorMessage":"taskId is null","messagePattern":"taskId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java","lineNumber":121,"sourceCode":"        if (executionIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of executionIds is empty\");\n        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use executionIds together with excludeLocalVariables\");\n        }\n        this.executionIds = executionIds;\n        return this;\n    }\n\n    public VariableInstanceQuery activityInstanceId(String activityInstanceId) {\n        this.activityInstanceId = activityInstanceId;\n        return this;\n    }\n\n    @Override\n    public VariableInstanceQuery taskId(String taskId) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n        if (excludeTaskRelated) {\n            throw new FlowableIllegalArgumentException(\"Cannot use taskId together with excludeTaskVariables\");\n        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use taskIds together with excludeLocalVariables\");\n        }\n        this.taskId = taskId;\n        return this;\n    }\n\n    @Override\n    public VariableInstanceQueryImpl taskIds(Set<String> taskIds) {\n        if (taskIds == null) {\n            throw new FlowableIllegalArgumentException(\"taskIds is null\");\n        }\n        if (taskIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of taskIds is empty\");","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java#L103-L139","documentation":"VariableInstanceQuery.taskId(String) requires a non-null task id. Passing null throws FlowableIllegalArgumentException immediately because filtering variables by an absent task is invalid. This is a query-build-time validation; no query executes.","triggerScenarios":"Passing a null taskId, typically from an uninitialized variable, a map lookup that missed, or a service method forwarding an optional task id as null.","commonSituations":"Task id looked up from an execution/process context where the current scope is not task-based (e.g. a service task, not a user task), yielding null.","solutions":["Validate the task id is non-null before building the query","Only call taskId() when a task id is actually available; use a different filter otherwise","Ensure the id source (e.g. DelegateTask.getId()) is used in a task-scoped context"],"exampleFix":"// before\nquery.taskId(taskId); // may be null\n// after\nif (taskId != null) {\n    query.taskId(taskId);\n}","handlingStrategy":"validation","validationCode":"if (taskId == null) {\n    throw new IllegalArgumentException(\"taskId is required\");\n}","typeGuard":"boolean hasTaskId(String taskId) { return taskId != null && !taskId.isBlank(); }","tryCatchPattern":"try {\n    query.taskId(taskId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().equals(\"taskId is null\")) {\n        // skip or use alternative query\n    } else { throw e; }\n}","preventionTips":["Verify the execution context actually provides a task id (user tasks only)","Null-check ids from map lookups and delegates before querying","Document that taskId() must come from a task-scoped context"],"tags":["flowable","null-check","query-validation","variable-instance-query"],"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"}