{"record":{"id":"f87f416ae55b5181","repo":"flowable/flowable-engine","slug":"could-not-find-task-instance-with-id","errorCode":null,"errorMessage":"Could not find task instance with id:","messagePattern":"Could not find task instance with id:","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskCollectionResource.java","lineNumber":400,"sourceCode":"    @ApiResponses(value = {\n            @ApiResponse(code = 201, message = \"Indicates request was successful and the tasks are returned\"),\n            @ApiResponse(code = 400, message = \"Indicates a parameter was passed in the wrong format or that delegationState has an invalid value (other than pending and resolved). The status-message contains additional information.\")\n    })\n    @PutMapping(value = \"/cmmn-runtime/tasks\", produces = \"application/json\")\n    public DataResponse<TaskResponse> bulkUpdateTasks(@RequestBody BulkTasksRequest bulkTasksRequest) {\n\n        if (bulkTasksRequest == null) {\n            throw new FlowableException(\"A request body was expected when bulk updating tasks.\");\n        }\n        if (bulkTasksRequest.getTaskIds() == null) {\n            throw new FlowableIllegalArgumentException(\"taskIds can not be null for bulk update tasks requests\");\n        }\n\n        Collection<Task> taskList = getTasksFromRequest(bulkTasksRequest.getTaskIds());\n\n        if (taskList.size() != bulkTasksRequest.getTaskIds().size()) {\n            taskList.stream().forEach(task -> bulkTasksRequest.getTaskIds().remove(task.getId()));\n            throw new FlowableObjectNotFoundException(\n                    \"Could not find task instance with id:\" + bulkTasksRequest.getTaskIds().stream().collect(Collectors.joining(\",\")));\n        }\n\n        // Populate the task properties based on the request\n        populateTasksFromRequest(taskList, bulkTasksRequest);\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.bulkUpdateTasks(taskList, bulkTasksRequest);\n        }\n\n        // Save the task and fetch again, it's possible that an\n        // assignment-listener has updated\n        // fields after it was saved so we can not use the in-memory task\n        taskService.bulkSaveTasks(taskList);\n\n        List<Task> taskResultList = getTasksFromRequest(bulkTasksRequest.getTaskIds());\n\n        DataResponse<TaskResponse> dataResponse = new DataResponse<>();","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskCollectionResource.java#L382-L418","documentation":"After fetching the tasks for bulkUpdateTasks, if the number of found tasks differs from the number of requested taskIds, at least one id was not found. The method removes the found ids from the request list, leaving only missing ids, and throws FlowableObjectNotFoundException listing them comma-separated.","triggerScenarios":"PUT /cmmn-runtime/tasks where any id in taskIds refers to a nonexistent, completed/deleted, or foreign-tenant task; duplicate ids can also contribute to count mismatch.","commonSituations":"Bulk update over ids collected earlier, some since completed; mixed environments (test vs prod ids); duplicate entries in taskIds.","solutions":["Validate all taskIds exist via the task query API before the bulk update","Remove or correct the missing ids listed in the exception message (the leftover ids after found ones are removed)","Avoid duplicate ids in taskIds","Catch FlowableObjectNotFoundException, parse the listed ids, and retry with only the existing tasks"],"exampleFix":"// before\nrestClient.bulkUpdate(taskIds) // taskIds contains completed task t9\n// after\nList<String> valid = taskIds.stream().filter(id -> taskExists(id)).collect(toList());\nrestClient.bulkUpdate(valid);","handlingStrategy":"validation","validationCode":"const existing = await queryTasks({ taskIds }); if (existing.length !== new Set(taskIds).size) throw new NotFound('some taskIds missing');","typeGuard":null,"tryCatchPattern":"try { await bulkUpdate(ids); } catch (e) { if (e.message.startsWith('Could not find task instance with id')) { /* parse missing ids, filter them out, retry */ } throw e; }","preventionTips":["Pre-check all ids exist before bulk operations","Deduplicate taskIds","Purge ids of completed tasks; use history endpoints for those"],"tags":["rest","task","not-found","bulk"],"backgroundTag":"entity-not-found","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"}