{"record":{"id":"10cc2e65fb80d25c","repo":"flowable/flowable-engine","slug":"it-is-not-allowed-to-add-an-attachment-to-a-suspen","errorCode":null,"errorMessage":"It is not allowed to add an attachment to a suspended ","messagePattern":"It is not allowed to add an attachment to a suspended ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/CreateAttachmentCmd.java","lineNumber":147,"sourceCode":"            eventDispatcher.dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, attachment, \n                    processInstanceId, processInstanceId, processDefinitionId), processEngineConfiguration.getEngineCfgKey());\n            eventDispatcher.dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, attachment, \n                    processInstanceId, processInstanceId, processDefinitionId), processEngineConfiguration.getEngineCfgKey());\n        }\n\n        return attachment;\n    }\n\n    protected TaskEntity verifyTaskParameters(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find task with id \" + taskId, Task.class);\n        }\n\n        if (task.isSuspended()) {\n            throw new FlowableException(\"It is not allowed to add an attachment to a suspended \" + task);\n        }\n\n        return task;\n    }\n\n    protected ExecutionEntity verifyExecutionParameters(CommandContext commandContext) {\n        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);\n\n        if (execution == null) {\n            throw new FlowableObjectNotFoundException(\"Process instance \" + processInstanceId + \" doesn't exist\", ProcessInstance.class);\n        }\n\n        if (execution.isSuspended()) {\n            throw new FlowableException(\"It is not allowed to add an attachment to a suspended \" + execution);\n        }\n\n        return execution;\n    }","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/CreateAttachmentCmd.java#L129-L165","documentation":"CreateAttachmentCmd refuses to add an attachment to a suspended task. While the task's process/case is suspended, mutating operations such as adding attachments are disallowed. A plain FlowableException with the task's toString is thrown.","triggerScenarios":"Calling TaskService.createAttachment on a task whose containing process instance (or standalone task) is in suspended state, i.e. task.isSuspended() is true.","commonSituations":"Suspended process instances during maintenance windows or after runtimeService.suspendProcessInstanceById(...); users uploading documents while the case is frozen for review; batch importers that suspend instances and still write attachments.","solutions":["Resume the suspended instance first: runtimeService.activateProcessInstanceById(instanceId) (or activate the task), then add the attachment.","Check suspension state before uploading: if the task is suspended, queue the attachment or inform the user.","Remove the suspension if it was set accidentally (e.g. leftover suspension policy in config)."],"exampleFix":"// before\ntaskService.createAttachment(null, taskId, null, name, desc, url);\n// after\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task.isSuspended()) {\n    runtimeService.activateProcessInstanceById(task.getProcessInstanceId());\n}\ntaskService.createAttachment(null, taskId, task.getProcessInstanceId(), name, desc, url);","handlingStrategy":"validation","validationCode":"Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null && task.isSuspended()) {\n    throw new IllegalStateException(\"Task \" + taskId + \" is suspended\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.createAttachment(null, taskId, pid, name, desc, url);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"suspended\")) { queueForLater(taskId, url); } else { throw e; }\n}","preventionTips":["Check isSuspended() on task/process instance before any write operation","Expose suspension state in your UI and disable upload controls","Coordinate with admins so suspension windows exclude interactive writes"],"tags":["flowable","suspended","attachment"],"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"}