{"record":{"id":"10a36a2c2fe214ee","repo":"theonedev/onedev","slug":"comment-too-long-10a36a","errorCode":null,"errorMessage":"Comment too long","messagePattern":"Comment too long","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/activity/PullRequestCommentPanel.java","lineNumber":99,"sourceCode":"\t\t\t}\n\n\t\t}, getComment().getDate()));\n\t\t\n\t\tadd(new CopyToClipboardLink(\"anchor\",\n\t\t\t\tModel.of(OneDev.getInstance(UrlService.class).urlFor(getComment(), true)),\n\t\t\t\t_T(\"Copy permanent link\")));\n\t\t\n\t\tadd(new CommentPanel(\"body\") {\n\n\t\t\t@Override\n\t\t\tprotected String getComment() {\n\t\t\t\treturn PullRequestCommentPanel.this.getComment().getContent();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected void onSaveComment(AjaxRequestTarget target, String comment) {\n\t\t\t\tif (comment.length() > PullRequestComment.MAX_CONTENT_LEN)\n\t\t\t\t\tthrow new ExplicitException(\"Comment too long\");\n\t\t\t\tvar entity = PullRequestCommentPanel.this.getComment();\n\n\t\t\t\tvar oldComment = entity.getContent();\n\t\t\t\tif (!oldComment.equals(comment)) {\n\t\t\t\t\ttransactionService.run(() -> {\n\t\t\t\t\t\tentity.setContent(comment);\n\t\t\t\t\t\tentity.setRevisionCount(entity.getRevisionCount() + 1);\n\t\t\t\t\t\tpullRequestCommentService.update(entity);\n\n\t\t\t\t\t\tvar revision = new PullRequestCommentRevision();\n\t\t\t\t\t\trevision.setComment(entity);\n\t\t\t\t\t\trevision.setUser(SecurityUtils.getUser());\n\t\t\t\t\t\trevision.setOldContent(oldComment);\n\t\t\t\t\t\trevision.setNewContent(comment);\n\t\t\t\t\t\tdao.persist(revision);\n\t\t\t\t\t});\n\t\t\t\t\tvar page = (BasePage) getPage();\n\t\t\t\t\tpage.notifyObservableChange(target, PullRequest.getChangeObservable(entity.getRequest().getId()));\t\t\t\t","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/activity/PullRequestCommentPanel.java#L81-L117","documentation":"PullRequestCommentPanel enforces PullRequestComment.MAX_CONTENT_LEN on comment edits; saving a longer comment throws ExplicitException which is surfaced to the user in the UI. It prevents oversized comment text from being persisted to the database.","triggerScenarios":"Editing or creating a pull request comment whose text exceeds MAX_CONTENT_LEN (e.g. pasting large logs/code blocks) and clicking save; programmatic UI automation submitting huge comment bodies.","commonSituations":"Pasting build logs, stack traces, or generated reports into a comment; migrating comments from another tracker without truncation; bots posting verbose output as PR comments.","solutions":["Shorten the comment to fit the length limit; move large content to a gist/file and link it.","Truncate programmatically before saving: if (comment.length() > PullRequestComment.MAX_CONTENT_LEN) comment = comment.substring(0, MAX_CONTENT_LEN).","For bots/integrations, enforce the limit in the posting code before calling the comment API."],"exampleFix":"// before\npanel.saveComment(hugeLogText);\n// after\nString text = hugeLogText;\nif (text.length() > PullRequestComment.MAX_CONTENT_LEN)\n    text = text.substring(0, PullRequestComment.MAX_CONTENT_LEN - 1) + \"\\n... (truncated)\";\npanel.saveComment(text);","handlingStrategy":"validation","validationCode":"if (comment != null && comment.length() > PullRequestComment.MAX_CONTENT_LEN)\n    throw new IllegalArgumentException(\"Comment exceeds \" + PullRequestComment.MAX_CONTENT_LEN + \" characters\");","typeGuard":"boolean commentFits(String c) { return c != null && c.length() <= PullRequestComment.MAX_CONTENT_LEN; }","tryCatchPattern":"try { saveComment(text); } catch (ExplicitException e) { notifyUser(\"Comment too long — please shorten it\"); }","preventionTips":["Truncate or offload large content (logs, dumps) to external storage before commenting.","Enforce MAX_CONTENT_LEN in any bot or integration that posts comments.","UI: show a character counter when composing comments."],"tags":["pull-requests","comments","validation","length-limit"],"backgroundTag":"value-out-of-range","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"}