{"record":{"id":"49538536a67ec0b4","repo":"flowable/flowable-engine","slug":"in-order-to-use-comments-history-should-be-enable-495385","errorCode":null,"errorMessage":"In order to use comments, history should be enabled","messagePattern":"In order to use comments, 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/CommentEntityManager.java","lineNumber":151,"sourceCode":"    public List<Comment> findCommentsByProcessInstanceId(String processInstanceId, String type) {\n        checkHistoryEnabled();\n        Map<String, Object> params = new HashMap<>();\n        params.put(\"processInstanceId\", processInstanceId);\n        params.put(\"type\", type);\n        return getDbSqlSession().selectListWithRawParameter(\"selectCommentsByProcessInstanceIdAndType\", params, 0, Integer.MAX_VALUE);\n    }\n\n    public Comment findComment(String commentId) {\n        return getDbSqlSession().selectById(CommentEntity.class, commentId);\n    }\n\n    public Event findEvent(String commentId) {\n        return getDbSqlSession().selectById(CommentEntity.class, commentId);\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","sourceCodeStart":133,"sourceCodeEnd":155,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CommentEntityManager.java#L133-L155","documentation":"ActivitiException thrown by CommentEntityManager.checkHistoryEnabled when a comment/event operation runs while history is disabled. Comments are implemented as history events, so with history level 'none' insert, delete, and all query methods reject the call. The engine fails fast rather than writing comments it could never read back.","triggerScenarios":"Calling TaskService.addComment(...), taskService.getTaskComments(...), getProcessInstanceComments, getComment/deleteComment, or any of the finder methods listed, while history is disabled (history=none).","commonSituations":"Performance-tuned engines with history=none encountering collaboration features (task comments) at runtime; code migrated from an environment with history enabled into one without.","solutions":["Enable history: set process.engine.history to 'activity' or higher in the engine configuration","Guard comment operations behind a historyEnabled check and degrade gracefully (e.g., store comments in an external service)","Catch ActivitiException around comment APIs when history support is optional in your deployment","Document that comments/attachments require history when choosing the history level"],"exampleFix":"// before\ntry {\n    taskService.addComment(taskId, processInstanceId, message);\n} catch (ActivitiException e) { /* comment lost */ }\n// after (enable history in config)\nprocessEngineConfig.setHistory(HistoryLevel.ACTIVITY.getKey());\ntaskService.addComment(taskId, processInstanceId, message);","handlingStrategy":"try-catch","validationCode":"if (!processEngine.getProcessEngineConfiguration().getHistoryManager().isHistoryEnabled()) {\n    throw new IllegalStateException(\"Comments require history to be enabled\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.addComment(taskId, processInstanceId, message);\n} catch (ActivitiException e) {\n    if (e.getMessage().contains(\"history should be enabled\")) {\n        // fallback: persist comment in an application-owned table\n    } else throw e;\n}","preventionTips":["Never configure history=none if comments/attachments are used","Gate collaboration features on history configuration at startup","Include history level in environment smoke tests"],"tags":["history","comments","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"}