{"record":{"id":"13a377c4dec5fe88","repo":"theonedev/onedev","slug":"comment-too-long","errorCode":null,"errorMessage":"Comment too long","messagePattern":"Comment too long","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/web/component/issue/activities/activity/IssueCommentPanel.java","lineNumber":104,"sourceCode":"\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 IssueCommentPanel.this.getComment().getContent();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected boolean isQuoteEnabled() {\n\t\t\t\treturn true;\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() > IssueComment.MAX_CONTENT_LEN)\n\t\t\t\t\tthrow new ExplicitException(\"Comment too long\");\n\t\t\t\tvar entity = IssueCommentPanel.this.getComment();\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\tissueCommentService.update(entity);\n\n\t\t\t\t\t\tvar revision = new IssueCommentRevision();\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.notifyObservablesChange(target, entity.getIssue().getChangeObservables(false));\t\t\t\t\n\t\t\t\t}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/component/issue/activities/activity/IssueCommentPanel.java#L86-L122","documentation":"IssueCommentPanel.onSaveComment() enforces IssueComment.MAX_CONTENT_LEN: a comment longer than the maximum throws this ExplicitException before any persistence happens. The limit keeps issue activity content and storage within sane bounds.","triggerScenarios":"Saving an issue comment whose length exceeds IssueComment.MAX_CONTENT_LEN, typically by pasting a very large log, stack trace, or document into the comment editor.","commonSituations":"Pasting multi-thousand-line CI logs or files into issue comments; API/scripts creating long issue comments; migrations importing verbose ticket bodies.","solutions":["Shorten the comment below IssueComment.MAX_CONTENT_LEN characters.","Attach large logs/files as issue attachments and keep only a summary in the comment.","Use a code block with only the relevant excerpt, or link to an external gist/artifact."],"exampleFix":"// before\npanel.onSaveComment(target, entireBuildLog);\n\n// after\nString content = entireBuildLog.length() > IssueComment.MAX_CONTENT_LEN\n    ? entireBuildLog.substring(0, IssueComment.MAX_CONTENT_LEN) + \"... (truncated, see attachment)\"\n    : entireBuildLog;\npanel.onSaveComment(target, content);","handlingStrategy":"validation","validationCode":"if (comment != null && comment.length() > IssueComment.MAX_CONTENT_LEN)\n    feedback.error(\"Comment exceeds \" + IssueComment.MAX_CONTENT_LEN + \" characters\");","typeGuard":"static boolean isCommentLengthOk(String s) {\n    return s != null && s.length() <= IssueComment.MAX_CONTENT_LEN;\n}","tryCatchPattern":"try {\n    panel.onSaveComment(target, comment);\n} catch (ExplicitException e) {\n    feedback.error(\"Comment too long; attach large logs as files instead\");\n}","preventionTips":["Truncate or attach large logs/files instead of pasting into comments.","Show a live character counter in the comment editor.","Enforce the same MAX_CONTENT_LEN limit in any API/script that creates comments."],"tags":["validation","length-limit","issue-comment"],"backgroundTag":"payload-too-large","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}