Skip to content

fix: process longer comments#137

Merged
corymhall merged 2 commits intov2-betafrom
corymhall/fix-long-comment
Jun 1, 2025
Merged

fix: process longer comments#137
corymhall merged 2 commits intov2-betafrom
corymhall/fix-long-comment

Conversation

@corymhall
Copy link
Owner

@corymhall corymhall commented Jun 1, 2025

This is the first step in attempting to solve the case when diff
comments are too long. From testing it looks like the comment limit that
the API returns (65535) is not the real limit, but it is hard to find
any concrete information on what the real limit is. I was able to post
some comments with a length > 150000.

Instead of doing any validation on our end and failing early, this PR
updates the logic to rely on the GH API failure message. We will always
attempt to comment and catch any "Body too long" errors that occur.

This should increase the size of the comment allowed and may fix the
issue for some users. I will follow up this with additional PRs fixing
the issue completely.

re #34

corymhall added 2 commits June 1, 2025 05:41
This is the first step in attempting to solve the case when diff
comments are too long. From testing it looks like the comment limit that
the API returns (65535) is not the real limit, but it is hard to find
any concrete information on what the real limit is. I was able to post
some comments with a length > 150000.

Instead of doing any validation on our end and failing early, this PR
updates the logic to rely on the GH API failure message. We will always
attempt to comment and catch any "Body too long" errors that occur.

This should increase the size of the comment allowed and may fix the
issue for some users. I will follow up this with additional PRs fixing
the issue completely.

re #34
@corymhall corymhall requested a review from Copilot June 1, 2025 09:52
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

This PR addresses the handling of overly long diff comments by removing the early length check and instead catching GitHub API “Body too long” errors.

  • Updated comment logic to rely on the API error message rather than a fixed MAX_COMMENT_LENGTH.
  • Refactored test code to accommodate the new error handling and adjusted expected mock call counts.
  • Modified comment processing to run stack comment posting in parallel with improved error aggregation.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/stage-processor.test.ts Updated tests with a new helper for setting up comment tests and adjusted mock call counts.
src/stage-processor.ts Refactored comment methods to remove fixed length checks and implement error handling using API error responses.
Comments suppressed due to low confidence (2)

src/stage-processor.ts:251

  • [nitpick] Consider ensuring that the items in the 'failed' array are converted to strings (e.g. using error.message) before joining them, to avoid ambiguous error outputs if the rejection reasons are not plain strings.
const failed = res.filter((r) => r.status === 'rejected').flatMap((r) => r.reason);

test/stage-processor.test.ts:503

  • [nitpick] The removal of the afterEach block that resets and restores mocks may lead to test leakage; consider reintroducing a cleanup step after each test to ensure test isolation.
-    jest.resetAllMocks(); // clears mock state

@corymhall corymhall merged commit 64c1750 into v2-beta Jun 1, 2025
6 checks passed
@corymhall corymhall deleted the corymhall/fix-long-comment branch June 1, 2025 10:23
rantoniuk added a commit to rantoniuk/corymhall-cdk-diff-action that referenced this pull request Jun 2, 2025
* v2-beta:
  fix: process longer comments (corymhall#137)
  fix: upgrade toolkit-lib and use stack displayName  (corymhall#134)
corymhall added a commit that referenced this pull request Jun 20, 2025
This is the first step in attempting to solve the case when diff
comments are too long. From testing it looks like the comment limit that
the API returns (65535) is not the real limit, but it is hard to find
any concrete information on what the real limit is. I was able to post
some comments with a length > 150000.

Instead of doing any validation on our end and failing early, this PR
updates the logic to rely on the GH API failure message. We will always
attempt to comment and catch any "Body too long" errors that occur.

This should increase the size of the comment allowed and may fix the
issue for some users. I will follow up this with additional PRs fixing
the issue completely.

re #34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants