RFR: 1450: Jcheck status message can be too big for Gitlab
Erik Joelsson
erikj at openjdk.org
Thu Oct 27 14:29:52 UTC 2022
On Wed, 26 Oct 2022 23:03:56 GMT, Zhao Song <zsong at openjdk.org> wrote:
> SKARA-1450 describes the problem that the comment adding to a GitLab merge request can be too big to add and leads to fail.
>
> To fix it, I add the function `limitBodySize()` to `addComment()` and `updateComment()` in `GitLabMergeRequest`, the function will check the size of the comment and the comment will be cropped if it is too big.
>
> I also found that GitHub pull request might have the same problem, so I did the same change to `GitHubPullRequest`.
>
> Currently, I set the comment max size to 20000, and I don't know whether it is fine. I think it could not be too small because the user wants to see more information and it should not be big because if it is too big, the page loading process will be slow when the user tries to open the pr.
>
> [Maximum length for the comment body in GitHub PR](https://github.com/orgs/community/discussions/27190)
> [My test in Playground](https://github.com/openjdk/playground/pull/99)
Comments on GitHubPullRequest also apply to GitLabMergeRequest.
forge/src/main/java/org/openjdk/skara/forge/github/GitHubPullRequest.java line 49:
> 47: private List<Label> labels = null;
> 48:
> 49: private static final int GITHUB_PR_COMMENT_BODY_MAX_SIZE = 20000;
I think we can bump this up a bit more. Maybe 64k is a reasonable number? Also consider using `_` to group long number constants into triplets for easier reading.
forge/src/main/java/org/openjdk/skara/forge/github/GitHubPullRequest.java line 793:
> 791: public String limitBodySize(String body) {
> 792: if (body.length() > GITHUB_PR_COMMENT_BODY_MAX_SIZE) {
> 793: return "⚠️This comment is too long, only the first "
I think ending with `...` is enough to indicate that the comment has been truncated. This will only apply to comments generated by the bot. If we start such a comment with a warning like this, it will risk confusing users.
-------------
PR: https://git.openjdk.org/skara/pull/1403
More information about the skara-dev
mailing list