{"record":{"id":"bddbe8b577858a30","repo":"flowable/flowable-engine","slug":"it-is-not-allowed-to-add-an-attachment-to-a-suspen-bddbe8","errorCode":null,"errorMessage":"It is not allowed to add an attachment to a suspended process instance","messagePattern":"It is not allowed to add an attachment to a suspended process instance","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/CreateAttachmentCmd.java","lineNumber":133,"sourceCode":"\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":115,"sourceCodeEnd":139,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/CreateAttachmentCmd.java#L115-L139","documentation":"The command refuses to attach content to a suspended process instance, throwing ActivitiException. Like suspended tasks, suspended executions are frozen: state-mutating related operations such as attachments are disallowed.","triggerScenarios":"createAttachment with a processInstanceId whose execution.isSuspended() is true, typically after suspendProcessInstanceById/ByProcessDefinitionId.","commonSituations":"Bulk suspend for maintenance or migration while document workflows keep running; an instance suspended by policy awaiting approval.","solutions":["Activate the process instance first (runtimeService.activateProcessInstanceById)","Check the suspension state before attaching and queue the operation","Attach the document to a task in a non-suspended instance instead"],"exampleFix":"// before\ntaskService.createAttachment(\"text\", null, procInstId, \"n\", \"d\", stream);\n// after\nProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(procInstId).singleResult();\nif (pi != null && !pi.isSuspended()) {\n    taskService.createAttachment(\"text\", null, procInstId, \"n\", \"d\", stream);\n}","handlingStrategy":"validation","validationCode":"ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(procInstId).singleResult();\nboolean allowed = pi != null && !pi.isSuspended();","typeGuard":"boolean canAttachToInstance(ProcessInstance pi) { return pi != null && !pi.isSuspended(); }","tryCatchPattern":"try { taskService.createAttachment(...); } catch (ActivitiException e) { if (e.getMessage().contains(\"suspended\")) { /* defer until activated */ } }","preventionTips":["Check isSuspended() on the instance before any write operation","Pause integrations during scheduled suspensions","Reactivate instances programmatically before resuming flows"],"tags":["suspended","process-instance","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"}