{"record":{"id":"627a6a4e36781dcf","repo":"flowable/flowable-engine","slug":"invalid-task-id-null","errorCode":null,"errorMessage":"Invalid task id : null","messagePattern":"Invalid task id : null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntityManager.java","lineNumber":111,"sourceCode":"            } else {\n                commandContext\n                        .getHistoryManager()\n                        .recordTaskEnd(taskId, deleteReason);\n            }\n\n            getDbSqlSession().delete(task);\n\n            if (commandContext.getEventDispatcher().isEnabled()) {\n                commandContext.getEventDispatcher().dispatchEvent(\n                        ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, task),\n                        EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);\n            }\n        }\n    }\n\n    public TaskEntity findTaskById(String id) {\n        if (id == null) {\n            throw new ActivitiIllegalArgumentException(\"Invalid task id : null\");\n        }\n        return (TaskEntity) getDbSqlSession().selectById(TaskEntity.class, id);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public List<TaskEntity> findTasksByExecutionId(String executionId) {\n        return getDbSqlSession().selectList(\"selectTasksByExecutionId\", executionId);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public List<TaskEntity> findTasksByProcessInstanceId(String processInstanceId) {\n        return getDbSqlSession().selectList(\"selectTasksByProcessInstanceId\", processInstanceId);\n    }\n\n    @Deprecated\n    public List<Task> findTasksByQueryCriteria(TaskQueryImpl taskQuery, Page page) {\n        taskQuery.setFirstResult(page.getFirstResult());\n        taskQuery.setMaxResults(page.getMaxResults());","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntityManager.java#L93-L129","documentation":"TaskEntityManager.findTaskById validates its argument and throws ActivitiIllegalArgumentException when the id is null before querying the database. This is a fail-fast guard: a null id would produce a meaningless or dangerous selectById. Note this is an IllegalArgumentException, not a generic ActivitiException, so catch accordingly.","triggerScenarios":"Calling taskService.createTaskQuery().taskId(null), TaskService-related APIs, or any engine path (including deleteTask with a null taskId) that resolves a task by id when the id variable is null/uninitialized.","commonSituations":"taskId taken from an unset request parameter or missing path variable; a variable holding the task id was never set in the process; deserialization produced a null id; copy/paste of query code with placeholder nulls.","solutions":["Null-check the task id in your code before calling any task lookup API","Trace where the id comes from (form field, process variable, REST param) and require it at the boundary","Catch ActivitiIllegalArgumentException and return a 400-style validation error to the caller"],"exampleFix":"// before\nTask task = taskService.createTaskQuery().taskId(requestParam).singleResult();\n// after\nif (requestParam == null || requestParam.isEmpty()) {\n    throw new BadRequestException(\"taskId is required\");\n}\nTask task = taskService.createTaskQuery().taskId(requestParam).singleResult();","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.trim().isEmpty()) throw new IllegalArgumentException(\"taskId required\");","typeGuard":"boolean isValidTaskId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\n} catch (ActivitiIllegalArgumentException e) {\n    throw new BadRequestException(\"taskId must be provided\");\n}","preventionTips":["Validate ids at the API boundary (REST param, form field)","Require non-null id variables in process definitions","Prefer query APIs with explicit null handling"],"tags":["validation","null","task","argument"],"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"}