{"record":{"id":"cc865cb4143abbc8","repo":"flowable/flowable-engine","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":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/AttachmentEntityManagerImpl.java","lineNumber":99,"sourceCode":"\n            dataManager.delete((AttachmentEntity) attachment);\n\n            if (dispatchEvents) {\n                eventDispatcher.dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, \n                        attachment, executionId, processInstanceId, processDefinitionId),\n                        engineConfiguration.getEngineCfgKey());\n            }\n        }\n    }\n    \n    @Override\n    public void bulkDeleteAttachmentsByTaskId(Collection<String> taskIds) {\n        dataManager.bulkDeleteAttachmentsByTaskId(taskIds);\n    }\n\n    protected void checkHistoryEnabled() {\n        if (!getHistoryManager().isHistoryEnabled()) {\n            throw new FlowableException(\"In order to use attachments, history should be enabled\");\n        }\n    }\n\n    protected HistoryManager getHistoryManager() {\n        return engineConfiguration.getHistoryManager();\n    }\n\n    protected ByteArrayEntityManager getByteArrayEntityManager() {\n        return engineConfiguration.getByteArrayEntityManager();\n    }\n\n}\n","sourceCodeStart":81,"sourceCodeEnd":112,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/AttachmentEntityManagerImpl.java#L81-L112","documentation":"Attachment queries and task-attachment deletion require Flowable's history (activity/audit) data because attachments are stored as history entities. AttachmentEntityManagerImpl.checkHistoryEnabled() throws this FlowableException whenever the engine's history level is configured to none.","triggerScenarios":"Calling TaskService/AttachmentService APIs such as findAttachmentsByProcessInstanceId, findAttachmentsByTaskId, or deleteAttachmentsByTaskId (bulkDelete) while processEngineConfiguration history is disabled (historyLevel = none, e.g. setHistoryLevel(HistoryLevel.NONE) or history config 'none').","commonSituations":"Deploying Flowable with history disabled for performance, then later adding attachment features; copying an engine config from a stateless/low-footprint setup; environment-specific config where historyLevel defaults to none.","solutions":["Enable history in the engine configuration, e.g. processEngineConfiguration.setHistoryLevel(HistoryLevel.ACTIVITY) (or AUDIT/FULL), or set flowable.history-level in properties.","If the DB schema was created with history tables absent (history none), run the schema update/creation so history tables exist after enabling history.","Refactor the code path to avoid attachment APIs if history must remain off (attachments are not supported without history)."],"exampleFix":"// before\nProcessEngineConfiguration cfg = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();\ncfg.setHistoryLevel(HistoryLevel.NONE);\n// after\nProcessEngineConfiguration cfg = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();\ncfg.setHistoryLevel(HistoryLevel.AUDIT); // attachments require history","handlingStrategy":"validation","validationCode":"// Java: check history is enabled before using attachments\nboolean historyEnabled(ProcessEngineConfigurationImpl cfg) {\n    return cfg.getHistoryManager().isHistoryEnabled();\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.getProcessInstanceAttachments(processInstanceId);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"history should be enabled\")) {\n        // surface config error to operator or fall back to non-history storage\n    } else { throw e; }\n}","preventionTips":["Configure historyLevel to at least ACTIVITY wherever attachments are used.","Add a startup assertion that history is enabled if attachment features are required.","Keep history config identical across environments.","Document that attachments depend on history tables."],"tags":["history","configuration","flowable","attachments"],"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"}