{"record":{"id":"d27f1e3dea47f1b7","repo":"flowable/flowable-engine","slug":"no-historic-task-exists-with-the-given-id-d27f1e","errorCode":null,"errorMessage":"No historic task exists with the given id: ","messagePattern":"No historic task exists with the given id: ","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java","lineNumber":61,"sourceCode":"    }\n\n    @Override\n    public List<HistoricIdentityLink> execute(CommandContext commandContext) {\n        if (taskId != null) {\n            return getLinksForTask(commandContext);\n        } else {\n            return getLinksForProcessInstance(commandContext);\n        }\n    }\n\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    protected List<HistoricIdentityLink> getLinksForTask(CommandContext commandContext) {\n        HistoricTaskInstanceEntity task = commandContext\n                .getHistoricTaskInstanceEntityManager()\n                .findHistoricTaskInstanceById(taskId);\n\n        if (task == null) {\n            throw new ActivitiObjectNotFoundException(\"No historic task exists with the given id: \" + taskId, HistoricTaskInstance.class);\n        }\n\n        List<HistoricIdentityLink> identityLinks = (List) commandContext\n                .getHistoricIdentityLinkEntityManager()\n                .findHistoricIdentityLinksByTaskId(taskId);\n\n        // Similar to GetIdentityLinksForTask, return assignee and owner as identity link\n        if (task.getAssignee() != null) {\n            HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();\n            identityLink.setUserId(task.getAssignee());\n            identityLink.setTaskId(task.getId());\n            identityLink.setType(IdentityLinkType.ASSIGNEE);\n            identityLinks.add(identityLink);\n        }\n        if (task.getOwner() != null) {\n            HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();\n            identityLink.setTaskId(task.getId());\n            identityLink.setUserId(task.getOwner());","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java#L43-L79","documentation":"When querying historic identity links by taskId, the command first loads the historic task instance. If no historic task exists with that id, it throws ActivitiObjectNotFoundException naming the id and HistoricTaskInstance.class.","triggerScenarios":"Calling the identity-links API with a taskId that does not exist in the historic tables — e.g. a task that never completed/started within history retention, a deleted history level ('none'/'activity'), or a mistyped/garbage-collected id.","commonSituations":"History level configured too low so tasks are not persisted; querying a running (not yet historic) task's id; stale ids from a cleaned-up database; typo between runtime task id and historic task id (they match, but only after history is written).","solutions":["Verify the taskId corresponds to an existing historic task via historyService.createHistoricTaskInstanceQuery().taskId(id).count()","Raise the history level (e.g. 'audit' or 'full') in process engine configuration so historic tasks are recorded","Catch ActivitiObjectNotFoundException and treat it as 'no history for this task'","Confirm the task actually finished or has history rows (ACT_HI_TASKINST) in the database"],"exampleFix":"// before\nList<HistoricIdentityLink> links = historyService.getHistoricIdentityLinksForTask(taskId);\n// after\nlong n = historyService.createHistoricTaskInstanceQuery().taskId(taskId).count();\nif (n == 0) { /* no historic task: skip or warn */ }\nelse { List<HistoricIdentityLink> links = ...; }","handlingStrategy":"try-catch","validationCode":"long count = historyService.createHistoricTaskInstanceQuery().taskId(taskId).count();\nboolean exists = count > 0;","typeGuard":"boolean historicTaskExists(String taskId) {\n    return taskId != null && historyService.createHistoricTaskInstanceQuery().taskId(taskId).count() > 0;\n}","tryCatchPattern":"try {\n    List<HistoricIdentityLink> links = ...;\n} catch (ActivitiObjectNotFoundException e) {\n    // no historic task for this id: return empty / 404\n}","preventionTips":["Set history level to 'audit' or 'full' so tasks are historicised","Only query history for tasks that have completed or started under history recording","Validate ids come from engine-issued values, not user free text"],"tags":["flowable","activiti","not-found","historic-task","identity-links"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}