{"record":{"id":"686aa826c87e25d2","repo":"flowable/flowable-engine","slug":"in-order-to-use-attachments-history-should-be-ena-686aa8","errorCode":null,"errorMessage":"In order to use attachments, history should be enabled","messagePattern":"In order to use attachments, history should be enabled","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/AttachmentEntityManager.java","lineNumber":80,"sourceCode":"\n        for (AttachmentEntity attachment : attachments) {\n            String contentId = attachment.getContentId();\n            if (contentId != null) {\n                getByteArrayManager().deleteByteArrayById(contentId);\n            }\n            getDbSqlSession().delete(attachment);\n            if (dispatchEvents) {\n                getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(\n                        ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, \n                                attachment, executionId, processInstanceId, processDefinitionId),\n                        EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);\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","sourceCodeStart":62,"sourceCodeEnd":84,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/AttachmentEntityManager.java#L62-L84","documentation":"ActivitiException thrown by AttachmentEntityManager.checkHistoryEnabled when an attachment operation is performed while history is disabled. Attachments are stored as history entities, so with history level 'none' the engine refuses the operation rather than silently losing data. It is a guard enforcing that the history subsystem is available before touching attachments.","triggerScenarios":"Calling TaskService.createAttachment(...) / getProcessInstanceAttachments / getTaskAttachments, or deleteAttachmentsByTaskId, when the engine is configured with history level none (historyManager.isHistoryEnabled() returns false).","commonSituations":"Engine configured with process.engine.history=none for performance, then code paths using attachments are exercised; production config hardened without auditing which APIs require history.","solutions":["Set history to at least 'activity' (e.g., process.engine.history=activity or HistoryLevel.ACTIVITY) in the engine configuration","If history must stay off, stop using attachments and store related documents in your own storage keyed by task/process id","Check getHistoryManager().isHistoryEnabled() before invoking attachment APIs","Wrap attachment calls in try-catch for ActivitiException with a graceful fallback"],"exampleFix":"// before (flowable.cfg.xml)\n<property name=\"history\" value=\"none\"/>\n// after\n<property name=\"history\" value=\"activity\"/>","handlingStrategy":"try-catch","validationCode":"if (!processEngine.getProcessEngineConfiguration().getHistoryManager().isHistoryEnabled()) {\n    throw new IllegalStateException(\"Attachments require history to be enabled\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.createAttachment(...);\n} catch (ActivitiException e) {\n    if (e.getMessage().contains(\"history should be enabled\")) {\n        // fallback: store attachment in external storage\n    } else throw e;\n}","preventionTips":["Set history level to 'activity' or higher when using attachments","Check isHistoryEnabled() before attachment APIs","Document history prerequisites for feature modules"],"tags":["history","attachments","configuration","unsupported-operation"],"backgroundTag":"feature-not-enabled","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}