theonedev/onedev · warning · ExplicitException

Comment too long

Error message

Comment too long

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/activity/PullRequestCommentPanel.java:99

			}

		}, getComment().getDate()));
		
		add(new CopyToClipboardLink("anchor",
				Model.of(OneDev.getInstance(UrlService.class).urlFor(getComment(), true)),
				_T("Copy permanent link")));
		
		add(new CommentPanel("body") {

			@Override
			protected String getComment() {
				return PullRequestCommentPanel.this.getComment().getContent();
			}

			@Override
			protected void onSaveComment(AjaxRequestTarget target, String comment) {
				if (comment.length() > PullRequestComment.MAX_CONTENT_LEN)
					throw new ExplicitException("Comment too long");
				var entity = PullRequestCommentPanel.this.getComment();

				var oldComment = entity.getContent();
				if (!oldComment.equals(comment)) {
					transactionService.run(() -> {
						entity.setContent(comment);
						entity.setRevisionCount(entity.getRevisionCount() + 1);
						pullRequestCommentService.update(entity);

						var revision = new PullRequestCommentRevision();
						revision.setComment(entity);
						revision.setUser(SecurityUtils.getUser());
						revision.setOldContent(oldComment);
						revision.setNewContent(comment);
						dao.persist(revision);
					});
					var page = (BasePage) getPage();
					page.notifyObservableChange(target, PullRequest.getChangeObservable(entity.getRequest().getId()));				

View on GitHub (pinned to d44925c47c)

Solutions

  1. Shorten the comment to fit the length limit; move large content to a gist/file and link it.
  2. Truncate programmatically before saving: if (comment.length() > PullRequestComment.MAX_CONTENT_LEN) comment = comment.substring(0, MAX_CONTENT_LEN).
  3. For bots/integrations, enforce the limit in the posting code before calling the comment API.

Example fix

// before
panel.saveComment(hugeLogText);
// after
String text = hugeLogText;
if (text.length() > PullRequestComment.MAX_CONTENT_LEN)
    text = text.substring(0, PullRequestComment.MAX_CONTENT_LEN - 1) + "\n... (truncated)";
panel.saveComment(text);
Defensive patterns

Strategy: validation

Validate before calling

if (comment != null && comment.length() > PullRequestComment.MAX_CONTENT_LEN)
    throw new IllegalArgumentException("Comment exceeds " + PullRequestComment.MAX_CONTENT_LEN + " characters");

Type guard

boolean commentFits(String c) { return c != null && c.length() <= PullRequestComment.MAX_CONTENT_LEN; }

Try / catch

try { saveComment(text); } catch (ExplicitException e) { notifyUser("Comment too long — please shorten it"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/10a36a2c2fe214ee. Report an issue: GitHub.