{"record":{"id":"95b7fe85a4948b9a","repo":"flowable/flowable-engine","slug":"task-id-is-null-95b7fe","errorCode":null,"errorMessage":"Task id is null","messagePattern":"Task id is null","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java","lineNumber":134,"sourceCode":"    }\n\n    public TaskQueryImpl(CommandContext commandContext) {\n        super(commandContext);\n    }\n\n    public TaskQueryImpl(CommandExecutor commandExecutor) {\n        super(commandExecutor);\n    }\n\n    public TaskQueryImpl(CommandExecutor commandExecutor, String databaseType) {\n        super(commandExecutor);\n        this.databaseType = databaseType;\n    }\n\n    @Override\n    public TaskQueryImpl taskId(String taskId) {\n        if (taskId == null) {\n            throw new ActivitiIllegalArgumentException(\"Task id is null\");\n        }\n\n        if (orActive) {\n            currentOrQueryObject.taskId = taskId;\n        } else {\n            this.taskId = taskId;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQueryImpl taskName(String name) {\n        if (name == null) {\n            throw new ActivitiIllegalArgumentException(\"Task name is null\");\n        }\n\n        if (orActive) {\n            currentOrQueryObject.name = name;","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java#L116-L152","documentation":"This is thrown by TaskQueryImpl.taskId() when the caller passes a null task id to the query builder. The Flowable/Activiti engine rejects null filter values up front instead of issuing a broken or unbounded SQL query. It is a fail-fast argument validation inside the fluent TaskQuery API.","triggerScenarios":"Calling taskService.createTaskQuery().taskId(null), typically when the task id variable is uninitialized or the result of a failed lookup was not checked before building the query.","commonSituations":"Chaining taskId(someMap.get(\"taskId\")) where the map key is absent; using a process variable that was never set; a refactor changed the source of the id and it now returns null.","solutions":["Ensure a non-null task id before calling taskId(), e.g. check the variable or lookup result first","Wrap the query build in a try-catch for ActivitiIllegalArgumentException to surface a friendly message","If the id is genuinely unknown, skip the query or use a different filter (e.g. processInstanceId) instead"],"exampleFix":"// before\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\n// after\nif (taskId != null) {\n    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\n}","handlingStrategy":"validation","validationCode":"if (taskId == null) { throw new IllegalArgumentException(\"taskId must be provided before querying\"); }","typeGuard":"boolean hasTaskId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try { return taskService.createTaskQuery().taskId(taskId).singleResult(); } catch (ActivitiIllegalArgumentException e) { log.warn(\"Invalid task query: {}\", e.getMessage()); return null; }","preventionTips":["Never pass variables straight from maps/config into taskId(); check null first","Centralize task query construction in one helper that validates inputs","Treat a null id as a business condition (no lookup), not a query input"],"tags":["java","query-builder","null-argument","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"}