Skip to content

Conversation

@MeNsaaH
Copy link
Collaborator

@MeNsaaH MeNsaaH commented Jul 13, 2025

Add feature to split comments across all vcs platforms while retaining codeblocks in between splits

Screen Shot 2025-07-26 at 7 40 21 PM

Closes #421 #301 #299

@github-actions
Copy link

Temporary image available at ghcr.io/zapier/kubechecks:0.0.0-pr436.

@MeNsaaH MeNsaaH changed the title feat: Split comments feat: Split comments if too long Jul 13, 2025
@MeNsaaH MeNsaaH force-pushed the link-messages branch 2 times, most recently from 0cd5aa3 to 251ab64 Compare July 13, 2025 18:14
@MeNsaaH MeNsaaH requested review from Greyeye, Copilot and djeebus July 13, 2025 22:25

This comment was marked as outdated.

@MeNsaaH MeNsaaH requested a review from Copilot July 13, 2025 22:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for splitting long VCS comments into multiple chunks with backoff retries and proper link headers.

  • Extended the Client interface to include max comment length and PR link template, and updated UpdateMessage to accept multiple message parts.
  • Implemented retry logic using exponential backoff in both GitLab and GitHub clients.
  • Added sophisticated comment-splitting logic in BuildComment to honor VCS size limits and preserve code blocks.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/vcs/types.go Updated Client interface with new methods and changed UpdateMessage signature
pkg/vcs/gitlab_client/message.go Added backoff retry and multi-part UpdateMessage implementation
pkg/vcs/github_client/message.go Added backoff retry and multi-part UpdateMessage implementation
pkg/vcs/github_client/backoff.go Added backoff configuration helper
pkg/msg/message.go Enhanced BuildComment with splitting logic and code-block handling
mocks/vcs/mocks/mock_MockClient.go Updated mocks for new interface methods and UpdateMessage signature
Comments suppressed due to low confidence (4)

pkg/vcs/types.go:21

  • The UpdateMessage signature was changed to accept a PullRequest and a slice of strings, but the doc comment wasn’t updated. Please update the comment to reflect the new parameters.
	// UpdateMessage update a message with new content

pkg/vcs/types.go:41

  • The comment refers to GetPrLinkTemplate but the method is named GetPrCommentLinkTemplate. Update the comment for consistency.
	// GetPrLinkTemplate returns the template for the PR link

pkg/msg/message.go:148

  • [nitpick] The BuildComment function is quite large and handles many responsibilities (header/footer, splitting, code‐block preservation). Consider extracting the split logic into smaller helper functions to improve readability and testability.
// BuildComment iterates the map of all apps in this message, building a final comment from their current state

mocks/vcs/mocks/mock_MockClient.go:798

  • [nitpick] The parameter name strings shadows the Go strings package and may be confusing. Consider renaming it to messages or commentChunks.
func (_mock *MockClient) UpdateMessage(context1 context.Context, pullRequest vcs.PullRequest, message *msg.Message, strings []string) error {

@Greyeye
Copy link
Collaborator

Greyeye commented Jul 15, 2025

@MeNsaaH
I deployed the kubechecks image to kubechecks-staging and tested it here

While it works (that's positive!), 2nd part of the comment (overflow) remains expanded and does not look good. I think this should be wrapped with

<details> or <summary>

But I think this feature should cut at the application level (like this),
or at least trim at the object level like

===== apiextensions.k8s.io/CustomResourceDefinition /envoyproxies.gateway.envoyproxy.io ======

wdyt?

@MeNsaaH
Copy link
Collaborator Author

MeNsaaH commented Jul 15, 2025

But I think this feature should cut at the application level (like this),
or at least trim at the object level like

the issue is with github, the max comment limit is 65553 characters which is far less than what's on gitlab (1million chars). With github there are cases, where the diff of single resource (object) could span multiple comments. So, splitting by object-level level would be impossible

@MeNsaaH MeNsaaH force-pushed the link-messages branch 4 times, most recently from da81a18 to 8a1059d Compare July 26, 2025 18:24
@MeNsaaH
Copy link
Collaborator Author

MeNsaaH commented Jul 26, 2025

@Greyeye it's all ready now. when you get sometime could you test and review

Copy link
Collaborator

@Greyeye Greyeye left a comment

Choose a reason for hiding this comment

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

left a comment on the use of builtin function and BuildComment function.

@MeNsaaH MeNsaaH requested a review from Greyeye August 15, 2025 18:45
@Greyeye
Copy link
Collaborator

Greyeye commented Aug 18, 2025

@MeNsaaH you'll have to run ./earthly +rebuild-docs' to fix the lint error.
otherwise LGTM

Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
MeNsaaH added 14 commits August 26, 2025 14:55
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
Signed-off-by: Mmadu Manasseh <[email protected]>
@MeNsaaH MeNsaaH requested review from Greyeye and Copilot September 14, 2025 15:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +316 to +317
var msg *string
msg = &check.Details
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

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

Using a pointer to string here is unnecessary complexity. The string can be handled directly since Go strings are already efficient for copying and slicing operations.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't want to copy the string value because it could be a huge memory issue

Signed-off-by: Mmadu Manasseh <[email protected]>
Copy link
Collaborator

@Greyeye Greyeye left a comment

Choose a reason for hiding this comment

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

LGTM

@inakiabt
Copy link

inakiabt commented Oct 23, 2025

Is there a way we can use this branch? We're having exactly this issue for a +250 apps repo and we are in the middle of a migration and would love to see the impact of our PR changes 🤓

Edit: found how :) testing

  deployment:
    image:
      tag: "0.0.0-pr436"

Edit 2: It works 👍

@DrFaust92
Copy link
Contributor

It also works for us, Greyeye / djeebus. apologies for pinging you like this but it would be great to merge this

@MeNsaaH
Copy link
Collaborator Author

MeNsaaH commented Oct 27, 2025

It also works for us, Greyeye / djeebus. apologies for pinging you like this but it would be great to merge this

I'm seeing some cases where this causes huge memory usage on kubechecks. I want to refactor the code to put this under a flag KUBECHECKS_COMMENT_OVERFLOW_BEHAVIOUR: truncate or split. I'd do that when I get some time

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.

Kubechecks comments can get cut off if the comment length is too long

5 participants