{"record":{"id":"2873fb4d1d627bf3","repo":"theonedev/onedev","slug":"code-comment-is-already-resolved-unresolved","errorCode":null,"errorMessage":"Code comment is already resolved/unresolved","messagePattern":"Code comment is already resolved/unresolved","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/service/impl/DefaultCodeCommentStatusChangeService.java","lineNumber":44,"sourceCode":"import io.onedev.server.persistence.annotation.Sessional;\nimport io.onedev.server.persistence.annotation.Transactional;\nimport io.onedev.server.service.CodeCommentStatusChangeService;\n\n@Singleton\npublic class DefaultCodeCommentStatusChangeService extends BaseEntityService<CodeCommentStatusChange>\n\t\timplements CodeCommentStatusChangeService {\n\n\t@Inject\n\tprivate ListenerRegistry listenerRegistry;\n\n\t@Transactional\n\t@Override\n\tpublic void create(CodeCommentStatusChange change, String note) {\n\t\tPreconditions.checkState(change.isNew());\n\t\t\n\t\tCodeComment comment = change.getComment();\n\t\tif (comment.isResolved() == change.isResolved())\n\t\t\tthrow new NotAcceptableException(\"Code comment is already \" + (change.isResolved() ? \"resolved\" : \"unresolved\"));\n\n\t\tcomment.setResolved(change.isResolved());\n\t\t\n\t\tdao.persist(change);\n\t\t\n\t\tif (note != null) {\n\t\t\tCodeCommentReply reply = new CodeCommentReply();\n\t\t\treply.setComment(comment);\n\t\t\treply.setCompareContext(change.getCompareContext());\n\t\t\treply.setContent(note);\n\t\t\treply.setDate(new Date(change.getDate().getTime() - 100));\n\t\t\treply.setUser(change.getUser());\n\t\t\tdao.persist(reply);\n\t\t\t\n\t\t\tcomment.setReplyCount(comment.getReplyCount()+1);\n\t\t}\n\t\tlistenerRegistry.post(new CodeCommentStatusChanged(change, note));\n\t\t","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/service/impl/DefaultCodeCommentStatusChangeService.java#L26-L62","documentation":"DefaultCodeCommentStatusChangeService.create guards against duplicate status changes: if the comment is already in the requested resolved/unresolved state, recording another identical change would be a no-op and is rejected.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultCodeCommentStatusChangeService.java:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the comment's current resolved state before recording a status change.","Skip the change when the target state equals the current state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}