{"record":{"id":"fc0e66e98d43296a","repo":"flowable/flowable-engine","slug":"no-historic-task-exists-with-the-given-id-fc0e66","errorCode":null,"errorMessage":"No historic task exists with the given id: ","messagePattern":"No historic task exists with the given id: ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java","lineNumber":63,"sourceCode":"        this.processInstanceId = processInstanceId;\n    }\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        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        HistoricTaskInstanceEntity task = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().getHistoricTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"No historic task exists with the given id: \" + taskId, HistoricTaskInstance.class);\n        }\n\n        HistoricIdentityLinkService historicIdentityLinkService = processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService();\n        List<HistoricIdentityLinkEntity> identityLinks = historicIdentityLinkService.findHistoricIdentityLinksByTaskId(taskId);\n\n        HistoricIdentityLinkEntity assigneeIdentityLink = null;\n        HistoricIdentityLinkEntity ownerIdentityLink = null;\n        for (HistoricIdentityLinkEntity historicIdentityLink : identityLinks) {\n            if (IdentityLinkType.ASSIGNEE.equals(historicIdentityLink.getType())) {\n                assigneeIdentityLink = historicIdentityLink;\n\n            } else if (IdentityLinkType.OWNER.equals(historicIdentityLink.getType())) {\n                ownerIdentityLink = historicIdentityLink;\n            }\n        }\n\n        // Similar to GetIdentityLinksForTask, return assignee and owner as identity link\n        if (task.getAssignee() != null && assigneeIdentityLink == null) {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java#L45-L81","documentation":"This FlowableObjectNotFoundException is thrown by GetHistoricIdentityLinksForTaskCmd when the historic task service cannot find a HistoricTaskInstance matching the supplied taskId. Historic identity links (assignee, owner, candidates) only exist as attachments to a historic task record, so if the historic task is absent there is nothing to return. The library throws rather than returning null so callers can distinguish 'bad id' from 'task with no identity links'.","triggerScenarios":"Calling HistoryService.getHistoricIdentityLinksForTask(taskId) (or RuntimeService variants routed here) with a taskId that has no row in ACT_HI_TASKINST — e.g. a still-running task never yet written to history, a deleted history, or a plain typo'd/transplanted id from another database.","commonSituations":"Querying history right after a task was created but before the history level flushes it; running with history level 'none' so no historic tasks are persisted; pointing an app at a different DB/schema (test vs prod) than where the id came from; hard-delete cleanup jobs removing historic data while reports still reference old ids.","solutions":["Verify the taskId exists in history: historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult() — if null, the id is wrong or history is gone","If the task is still running, fetch identity links from TaskService.getIdentityLinksForTask(taskId) instead of the history API","Check the engine's historyLevel configuration; at level 'none' or 'activity' fewer/no historic task records are produced","Confirm you are connected to the same database the id was issued from (datasource/JNDI config)","Wrap the call in try/catch for FlowableObjectNotFoundException and handle the absent-task case gracefully"],"exampleFix":"// before\nList<HistoricIdentityLink> links = historyService.getHistoricIdentityLinksForTask(taskId);\n// after\nHistoricTaskInstance ht = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();\nList<HistoricIdentityLink> links = (ht != null)\n    ? historyService.getHistoricIdentityLinksForTask(taskId)\n    : Collections.emptyList();","handlingStrategy":"try-catch","validationCode":"HistoricTaskInstance ht = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();\nif (ht == null) { /* task not in history: skip or use runtime TaskService */ }","typeGuard":"boolean historicTaskExists(String id) {\n  return id != null && historyService.createHistoricTaskInstanceQuery().taskId(id).count() > 0;\n}","tryCatchPattern":"try {\n  List<HistoricIdentityLink> links = historyService.getHistoricIdentityLinksForTask(taskId);\n} catch (FlowableObjectNotFoundException e) {\n  logger.warn(\"No historic task for id {}: {}\", taskId, e.getMessage());\n  links = Collections.emptyList();\n}","preventionTips":["Check the historic task exists before querying its identity links","For active tasks use TaskService identity-link APIs, not the history API","Verify history level configuration produces historic task records","Ensure all environments point at the same database as the id source"],"tags":["flowable","history","not-found","identity-link"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}