Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Gitlab Server comments if over max length #1755

Merged
merged 1 commit into from Aug 30, 2021

Conversation

krrrr38
Copy link
Contributor

@krrrr38 krrrr38 commented Aug 12, 2021

close #798

Motivation

If a comment is too long, a gitlab server returns a following error.

2019/10/03 03:07:12+0000 [EROR] command_runner.go:390 REPO_PATH_OBSCURED#247: Unable to comment: POST URL_OBSCURED: 400 {message: 400 (Bad request) "Note {:note=>["is too long (maximum is 1000000 characters)"]}" not given}

How to solve

Migrate implementation from other vcs server to split comment.

sepEnd := "\n```\n</details>" +
"\n<br>\n\n**Warning**: Output length greater than max comment size. Continued in next comment."
sepStart := "Continued from previous comment.\n<details><summary>Show Output</summary>\n\n" +
"```diff\n"
// maxCommentLength is the maximum number of chars allowed in a single comment
// This length was copied from the Github client - haven't found documentation
// or tested limit in Azure DevOps.
const maxCommentLength = 150000
comments := common.SplitComment(comment, maxCommentLength, sepEnd, sepStart)

@krrrr38 krrrr38 requested a review from a team as a code owner August 12, 2021 10:51
@@ -34,6 +34,10 @@ import (
gitlab "github.com/xanzy/go-gitlab"
)

// gitlabMaxCommentLength is the maximum number of chars allowed by Gitlab in a
// single comment.
const gitlabMaxCommentLength = 1000000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.gitlab.com/ce/api/notes.html#create-new-merge-request-note

body (required) - The content of a note. Limited to 1,000,000 characters.

@nishkrishnan nishkrishnan merged commit 4294042 into runatlantis:master Aug 30, 2021
@krrrr38 krrrr38 deleted the split-gitlab-comment branch August 30, 2021 22:00
krrrr38 added a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Help Needed] Long comment not allowed in gitlab
2 participants