{"record":{"id":"8bedb2ff440e6869","repo":"flowable/flowable-engine","slug":"it-is-not-allowed-to-add-an-attachment-to-a-suspen-8bedb2","errorCode":null,"errorMessage":"It is not allowed to add an attachment to a suspended task","messagePattern":"It is not allowed to add an attachment to a suspended task","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/CreateAttachmentCmd.java","lineNumber":121,"sourceCode":"            commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(\n                    ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, \n                            attachment, processInstanceId, processInstanceId, processDefinitionId),\n                    EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);\n        }\n\n        return attachment;\n    }\n\n    private void verifyParameters(CommandContext commandContext) {\n        if (taskId != null) {\n            TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);\n\n            if (task == null) {\n                throw new ActivitiObjectNotFoundException(\"Cannot find task with id \" + taskId, Task.class);\n            }\n\n            if (task.isSuspended()) {\n                throw new ActivitiException(\"It is not allowed to add an attachment to a suspended task\");\n            }\n        }\n\n        if (processInstanceId != null) {\n            ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);\n\n            if (execution == null) {\n                throw new ActivitiObjectNotFoundException(\"Process instance \" + processInstanceId + \" doesn't exist\", ProcessInstance.class);\n            }\n\n            if (execution.isSuspended()) {\n                throw new ActivitiException(\"It is not allowed to add an attachment to a suspended process instance\");\n            }\n        }\n    }\n\n}\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/CreateAttachmentCmd.java#L103-L139","documentation":"Suspended-state invariant in CreateAttachmentCmd.verifyParameters: attachments cannot be added while the task's process definition is suspended; the check protects suspended deployments from modification.","triggerScenarios":"Adding an attachment to a task whose process instance (or the task itself) was suspended via runtimeService.suspendProcessInstanceById / suspendProcessInstanceByProcessDefinitionId.","commonSituations":"An admin suspended a process definition or instance pending a fix, and users still try to enrich tasks; automated document pipelines keep posting attachments during a suspension window.","solutions":["Resume the process instance/task (runtimeService.activateProcessInstanceById) before attaching","Check task.isSuspended() or the execution state before calling createAttachment","Redirect the attachment to a different target or queue it until the suspension is lifted"],"exampleFix":"// before\ntaskService.createAttachment(\"text\", taskId, null, \"n\", \"d\", stream);\n// after\nTask t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t != null && !t.isSuspended()) {\n    taskService.createAttachment(\"text\", taskId, null, \"n\", \"d\", stream);\n}","handlingStrategy":"validation","validationCode":"Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\nboolean allowed = t != null && !t.isSuspended();","typeGuard":"boolean canAttach(Task t) { return t != null && !t.isSuspended(); }","tryCatchPattern":"try { taskService.createAttachment(...); } catch (ActivitiException e) { if (e.getMessage().contains(\"suspended\")) { /* queue or resume first */ } }","preventionTips":["Check suspension state before mutating tasks","Track suspension windows operationally and pause dependent automation","Resume instances before resuming document pipelines"],"tags":["suspended","task","attachment","state"],"backgroundTag":"invalid-state-transition","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"}