{"record":{"id":"65ec9e43d01b5274","repo":"halo-dev/halo","slug":"problemdetail-comment-turnedoff","errorCode":"problemDetail.comment.turnedOff","errorMessage":"The comment function has been turned off.","messagePattern":"The comment function has been turned off\\.","errorType":"http","errorClass":"AccessDeniedException","httpStatus":403,"severity":"error","filePath":"application/src/main/java/run/halo/app/core/endpoint/theme/CommentFinderEndpoint.java","lineNumber":174,"sourceCode":"\n    private <T> RateLimiterOperator<T> createIpBasedRateLimiter(ServerRequest request) {\n        var clientIp = IpAddressUtils.getIpAddress(request);\n        var rateLimiter = rateLimiterRegistry.rateLimiter(\"comment-creation-from-ip-\" + clientIp, \"comment-creation\");\n        return RateLimiterOperator.of(rateLimiter);\n    }\n\n    Mono<ServerResponse> createReply(ServerRequest request) {\n        String commentName = request.pathVariable(\"name\");\n        return request.bodyToMono(ReplyRequest.class)\n                .flatMap(replyRequest -> {\n                    Reply reply = replyRequest.toReply();\n                    reply.getSpec().setIpAddress(IpAddressUtils.getIpAddress(request));\n                    reply.getSpec().setUserAgent(HaloUtils.userAgentFrom(request));\n                    return environmentFetcher\n                            .fetchComment()\n                            .map(commentSetting -> {\n                                if (isFalse(commentSetting.getEnable())) {\n                                    throw new AccessDeniedException(\n                                            \"The comment function has been turned off.\",\n                                            \"problemDetail.comment.turnedOff\",\n                                            null);\n                                }\n                                if (checkReplyOwner(reply, commentSetting.getSystemUserOnly())) {\n                                    throw new AccessDeniedException(\n                                            \"Allow only system users to comment.\",\n                                            \"problemDetail.comment.systemUsersOnly\",\n                                            null);\n                                }\n                                reply.getSpec().setApproved(isFalse(commentSetting.getRequireReviewForNew()));\n\n                                if (reply.getSpec().getHidden() == null) {\n                                    reply.getSpec().setHidden(false);\n                                }\n\n                                return reply;\n                            })","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/theme/CommentFinderEndpoint.java#L156-L192","documentation":"Thrown as an AccessDeniedException (HTTP 403) with code 'problemDetail.comment.turnedOff' during CommentFinderEndpoint.createReply. Before persisting a reply, the endpoint fetches comment settings; if commentSetting.enable is false, replies are refused. This is a configuration gate, not an authentication failure.","triggerScenarios":"POST to the theme comment reply endpoint after an administrator disabled comments in the site's Comment settings (CommentSetting.enable = false).","commonSituations":"Site owner turned off comments globally; a theme still shows the reply form; cached front-end rendered the form before the setting propagated; admin disabled comments during moderation.","solutions":["Have an administrator re-enable comments in Settings > Comment, then retry.","Hide/disable the reply form in the theme when comments are turned off so users cannot attempt submission.","Handle the 403/code 'problemDetail.comment.turnedOff' in the UI with a friendly 'comments disabled' notice."],"exampleFix":"// before: form always shown; user clicks submit -> 403\n// after: theme checks comment enabled flag and hides the reply form when off","handlingStrategy":"try-catch","validationCode":"// before showing a reply form, fetch comment settings and check enable\nboolean commentsEnabled = commentSetting.enable;\nif (!commentsEnabled) { hideReplyForm(); }","typeGuard":null,"tryCatchPattern":"// handle the 403 with code problemDetail.comment.turnedOff gracefully\ntry {\n    commentApi.createReply(...);\n} catch (AccessDeniedException e) {\n    if (\"problemDetail.comment.turnedOff\".equals(e.getCode())) {\n        showInfo(\"Comments are disabled on this site.\");\n    } else throw e;\n}","preventionTips":["Hide comment forms in the theme when comments are disabled.","Surface the turnedOff code as a localized, non-alarming message."],"tags":["comment","access-denied","configuration","i18n","webflux"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}