{"record":{"id":"167776d39248c22e","repo":"Activiti/Activiti","slug":"in-order-to-use-comments-history-should-be-enable","errorCode":null,"errorMessage":"In order to use comments, history should be enabled","messagePattern":"In order to use comments, 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/CommentEntityManagerImpl.java","lineNumber":187,"sourceCode":"                if (process != null) {\n                    processDefinitionId = process.getProcessDefinitionId();\n                }\n            }\n            getEventDispatcher().dispatchEvent(\n                ActivitiEventBuilder.createEntityEvent(\n                    ActivitiEventType.ENTITY_DELETED,\n                    commentEntity,\n                    processInstanceId,\n                    processInstanceId,\n                    processDefinitionId\n                )\n            );\n        }\n    }\n\n    protected void checkHistoryEnabled() {\n        if (!getHistoryManager().isHistoryEnabled()) {\n            throw new ActivitiException(\"In order to use comments, history should be enabled\");\n        }\n    }\n\n    public CommentDataManager getCommentDataManager() {\n        return commentDataManager;\n    }\n\n    public void setCommentDataManager(CommentDataManager commentDataManager) {\n        this.commentDataManager = commentDataManager;\n    }\n}\n","sourceCodeStart":169,"sourceCodeEnd":199,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CommentEntityManagerImpl.java#L169-L199","documentation":"Activiti stores comments and events as history entities, so comment operations require history to be enabled. CommentEntityManagerImpl.checkHistoryEnabled throws this ActivitiException when the history manager reports history disabled (history level 'none'). The engine refuses the operation because there is nowhere to persist comments.","triggerScenarios":"Calling taskService.addComment(...), getTaskComments, getProcessInstanceComments, or event lookup methods while the engine's historyLevel is none (config uses HistoryLevel.NONE or xml value 'none').","commonSituations":"Engines tuned with history disabled for performance; same codebase deployed to an environment whose activiti.cfg.xml differs; upgrade where history config was dropped; new feature using comments added to a history-free setup.","solutions":["Enable history in config: set historyLevel to activity/audit (setHistoryLevel(HistoryLevel.ACTIVITY) or <property name=\"historyLevel\" value=\"audit\"/>).","Redeploy/restart the engine with the corrected configuration.","If history must remain disabled, replace Activiti comments with an application-level comment store.","Gate comment code on processEngineConfiguration.getHistoryLevel() != HistoryLevel.NONE."],"exampleFix":"// before\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(\"Comments require history to be enabled\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.addComment(taskId, procInstId, message);\n} catch (org.activiti.engine.ActivitiException e) {\n    if (e.getMessage().contains(\"history should be enabled\")) {\n        throw new MisconfiguredEngineException(\"Enable history to use comments\", e);\n    }\n    throw e;\n}","preventionTips":["Enable historyLevel audit wherever comment APIs are used","Verify history configuration after engine upgrades","Startup-check historyLevel before exposing comment features"],"tags":["history","comments","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"}