{"record":{"id":"e95a7326d8b014db","repo":"Activiti/Activiti","slug":"in-order-to-use-attachments-history-should-be-ena","errorCode":null,"errorMessage":"In order to use attachments, history should be enabled","messagePattern":"In order to use attachments, history should be enabled","errorType":"validation","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/AttachmentEntityManagerImpl.java","lineNumber":111,"sourceCode":"            attachmentDataManager.delete((AttachmentEntity) attachment);\n\n            if (dispatchEvents) {\n                getEventDispatcher().dispatchEvent(\n                    ActivitiEventBuilder.createEntityEvent(\n                        ActivitiEventType.ENTITY_DELETED,\n                        attachment,\n                        executionId,\n                        processInstanceId,\n                        processDefinitionId\n                    )\n                );\n            }\n        }\n    }\n\n    protected void checkHistoryEnabled() {\n        if (!getHistoryManager().isHistoryEnabled()) {\n            throw new ActivitiException(\"In order to use attachments, history should be enabled\");\n        }\n    }\n\n    public AttachmentDataManager getAttachmentDataManager() {\n        return attachmentDataManager;\n    }\n\n    public void setAttachmentDataManager(AttachmentDataManager attachmentDataManager) {\n        this.attachmentDataManager = attachmentDataManager;\n    }\n}\n","sourceCodeStart":93,"sourceCodeEnd":123,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/AttachmentEntityManagerImpl.java#L93-L123","documentation":"Activiti stores attachments as history entities, so any attachment operation requires the process engine history to be enabled. AttachmentEntityManagerImpl.checkHistoryEnabled throws this ActivitiException when isHistoryEnabled() returns false (history level 'none'). Without history there is no table where attachment rows live.","triggerScenarios":"Calling TaskService.createAttachment(...), taskService.getProcessInstanceAttachments / getTaskAttachments, or deleting attachments by task while engine config has historyLevel set to none (processEngineConfiguration.setHistoryLevel(HistoryLevel.NONE) or historyLevel none in config).","commonSituations":"Performance-tuned engines that disabled history, then code paths using attachments fail; environment config (prod) differing from dev where history was on; adding attachment features to an app that was configured history-free from the start.","solutions":["Enable history: set historyLevel to at least ACTIVITY (e.g. <property name=\"historyLevel\" value=\"audit\"/> in activiti.cfg.xml or setHistoryLevel(HistoryLevel.ACTIVITY)).","Restart/rebuild the engine so the new history level applies; old engines with none need the schema intact (it is, history tables just stay unused).","If history must stay off, stop using attachment APIs and store attachments in your own application tables.","Check historyLevel programmatically: processEngineConfiguration.getHistoryLevel() before calling attachment APIs."],"exampleFix":"// before (activiti.cfg.xml)\n<property name=\"historyLevel\" value=\"none\"/>\n// after\n<property name=\"historyLevel\" value=\"audit\"/>","handlingStrategy":"validation","validationCode":"if (processEngineConfig.getHistoryLevel() == org.activiti.engine.impl.history.HistoryLevel.NONE) {\n    throw new IllegalStateException(\"Attachments require history to be enabled\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.createAttachment(type, taskId, procInstId, name, desc, content);\n} catch (org.activiti.engine.ActivitiException e) {\n    if (e.getMessage().contains(\"history should be enabled\")) {\n        throw new MisconfiguredEngineException(\"Enable history to use attachments\", e);\n    }\n    throw e;\n}","preventionTips":["Set historyLevel to at least activity in every environment using attachments","Keep activiti.cfg.xml identical across dev/prod for history settings","Assert historyLevel at application startup"],"tags":["history","attachments","configuration"],"backgroundTag":"feature-not-enabled","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}