{"record":{"id":"a433cb8d98c03572","repo":"flowable/flowable-engine","slug":"invalid-historic-task-id-null","errorCode":null,"errorMessage":"Invalid historic task id : null","messagePattern":"Invalid historic task id : null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/HistoricTaskInstanceEntityManager.java","lineNumber":99,"sourceCode":"                if (firstResult > 0) {\n                    if (firstResult <= instanceList.size()) {\n                        int toIndex = firstResult + Math.min(maxResults, instanceList.size() - firstResult);\n                        return instanceList.subList(firstResult, toIndex);\n                    } else {\n                        return Collections.EMPTY_LIST;\n                    }\n                } else {\n                    int toIndex = Math.min(maxResults, instanceList.size());\n                    return instanceList.subList(0, toIndex);\n                }\n            }\n        }\n        return Collections.EMPTY_LIST;\n    }\n\n    public HistoricTaskInstanceEntity findHistoricTaskInstanceById(String taskId) {\n        if (taskId == null) {\n            throw new ActivitiIllegalArgumentException(\"Invalid historic task id : null\");\n        }\n        if (getHistoryManager().isHistoryEnabled()) {\n            return (HistoricTaskInstanceEntity) getDbSqlSession().selectOne(\"selectHistoricTaskInstance\", taskId);\n        }\n        return null;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public List<HistoricTaskInstance> findHistoricTasksByParentTaskId(String parentTaskId) {\n        return getDbSqlSession().selectList(\"selectHistoricTasksByParentTaskId\", parentTaskId);\n    }\n\n    public void deleteHistoricTaskInstanceById(String taskId) {\n        if (getHistoryManager().isHistoryEnabled()) {\n            HistoricTaskInstanceEntity historicTaskInstance = findHistoricTaskInstanceById(taskId);\n            if (historicTaskInstance != null) {\n                CommandContext commandContext = Context.getCommandContext();\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/HistoricTaskInstanceEntityManager.java#L81-L117","documentation":"findHistoricTaskInstanceById requires a non-null task id and fails fast with ActivitiIllegalArgumentException otherwise. It validates arguments before hitting the database and also returns null (rather than throwing) when history is disabled.","triggerScenarios":"Calling HistoryService.createHistoricTaskInstanceQuery()... or the entity manager method with a null taskId; passing a variable that was never initialized; binding an optional path/request parameter that is missing.","commonSituations":"REST handlers that don't validate the id parameter; code paths after a task lookup returned null and the null was propagated; unit tests exercising historic queries with placeholder nulls.","solutions":["Ensure the taskId is non-null before calling; fail early in your own code with a clear message.","Null-check optional inputs (e.g., from HTTP params) before querying history.","If the id may legitimately be absent, guard with an existence query first."],"exampleFix":"// before\nHistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();\n\n// after\nif (id == null) throw new IllegalArgumentException(\"historic task id required\");\nHistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.isBlank()) {\n    throw new IllegalArgumentException(\"historic task id required\");\n}","typeGuard":"function hasHistoricTaskId(params) {\n  return typeof params.taskId === 'string' && params.taskId.length > 0;\n}","tryCatchPattern":"try {\n    return historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();\n} catch (ActivitiIllegalArgumentException e) {\n    return null; // or rethrow with your own message\n}","preventionTips":["Validate request/path parameters before querying history","Don't propagate null ids from earlier lookups","Check isHistoryEnabled when historic data is optional"],"tags":["null-argument","history","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-18T11:17:12.947Z"}